--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.tools.run\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.tools;\r
+\r
+import java.io.IOException;\r
+import org.apache.derby.drda.NetworkServerControl;\r
+import org.apache.derby.tools.dblook;\r
+import org.apache.derby.tools.ij;\r
+import org.apache.derby.tools.sysinfo;\r
+import org.apache.derby.iapi.tools.i18n.LocalizedResource;\r
+\r
+/**\r
+ <p>\r
+ The run class facilitates running the various Derby utilities with the\r
+ java -jar command. For example:\r
+ <p>\r
+ java -jar derbyrun.jar ij [-p propertiesfile] [sql script]<br>\r
+ java -jar derbyrun.jar sysinfo [-cp ...] [-cp help]<br>\r
+ java -jar derbyrun.jar dblook [args] (or no arguments for usage)<br>\r
+ java -jar derbyrun.jar server [args] (or no arguments for usage)<br>\r
+*/\r
+public class run {\r
+\r
+ /**\r
+ Switch on the first argument to choose the tool, pass the remaining\r
+ arguments to the tool.\r
+ */\r
+ static public void main(String[] args) throws IOException {\r
+ if (args.length < 1) {\r
+ printUsage();\r
+ } else if (args[0].equals("ij")) {\r
+ ij.main(trimArgs(args));\r
+ } else if (args[0].equals("sysinfo")) {\r
+ sysinfo.main(trimArgs(args));\r
+ } else if (args[0].equals("dblook")) {\r
+ dblook.main(trimArgs(args));\r
+ } else if (args[0].equals("server")) {\r
+ NetworkServerControl.main(trimArgs(args));\r
+ } else printUsage();\r
+ }\r
+\r
+ /**\r
+ Private constructor. No instances allowed.\r
+ */\r
+ private run() { \r
+ }\r
+ \r
+ /**\r
+ Utility method to trim one element off of the argument array.\r
+ @param args the arguments array\r
+ @return trimmed the trimmed array\r
+ */\r
+ private static String[] trimArgs(String[] args)\r
+ {\r
+ String [] trimmed = new String[args.length - 1];\r
+ System.arraycopy(args, 1, trimmed, 0, args.length - 1);\r
+ return trimmed; \r
+ }\r
+\r
+ /**\r
+ Print the usage statement if the user didn't enter a valid choice\r
+ of tool.\r
+ */\r
+ public static void printUsage()\r
+ {\r
+ LocalizedResource locRes = LocalizedResource.getInstance();\r
+ System.err.println(locRes.getTextMessage("RUN_Usage"));\r
+ }\r
+}\r