Title: [2485] trunk/openejb1: Took the responsibility of handling help and arguments out of the scripts and into the Main class.
- Revision
- 2485
- Author
- jcscoobyrs
- Date
- 2006-02-22 16:14:40 -0500 (Wed, 22 Feb 2006)
Log Message
Took the responsibility of handling help and arguments out of the scripts and into the Main class. OpenEJB startup scripts are now nearly empty.
Modified Paths
Diff
Modified: trunk/openejb1/maven.xml (2484 => 2485)
--- trunk/openejb1/maven.xml 2006-02-22 21:00:42 UTC (rev 2484)
+++ trunk/openejb1/maven.xml 2006-02-22 21:14:40 UTC (rev 2485)
@@ -390,6 +390,10 @@
<include name="*.cmd"/>
</fixcrlf>
+ <replace file="${aggregate.dir}/bin/openejb"
+ token="@REPLACED-BY-MAVEN-XML@"
+ value="${pom.currentVersion}"/>
+
<replace file="${aggregate.dir}/bin/openejb.bat"
token="@REPLACED-BY-MAVEN-XML@"
value="${pom.currentVersion}"/>
Modified: trunk/openejb1/modules/core/src/bin/openejb (2484 => 2485)
--- trunk/openejb1/modules/core/src/bin/openejb 2006-02-22 21:00:42 UTC (rev 2484)
+++ trunk/openejb1/modules/core/src/bin/openejb 2006-02-22 21:14:40 UTC (rev 2485)
@@ -57,150 +57,4 @@
OPENEJB_HOME=`cygpath --path --windows "$OPENEJB_HOME"`
fi
-echo OPENEJB_HOME = $OPENEJB_HOME
-
-OPTIONS="-Dopenejb.home=$OPENEJB_HOME"
-
-#============================================================
-_command_help()
-{
- case $2 in
- "validate")
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar validate --help
- ;;
- "deploy")
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar deploy --help
- ;;
- "start")
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar start --help
- ;;
- "stop")
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar stop --help
- ;;
- "test")
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test --help
- ;;
- *)
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar
- ;;
- esac
-}
-#============================================================
-_command_deploy()
-{
- shift
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar deploy $@
-}
-#============================================================
-_command_validate()
-{
- shift
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar validate $@
-}
-#============================================================
-_command_start()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar start $@
-}
-#============================================================
-_command_stop()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar stop $@
-}
-#============================================================
-_test_intravm()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test local
-}
-#============================================================
-_test_server()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test remote
-}
-#============================================================
-_test_http()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test http
-}
-#============================================================
-_test_tomcat()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test tomcat
-}
-#============================================================
-_command_test()
-{
-case $2 in
- "local")
- _test_intravm
- ;;
- "remote")
- _test_server
- ;;
- "http")
- _test_http
- ;;
- "tomcat")
- _test_tomcat
- ;;
- "--help")
- _test_help
- ;;
- *)
- _test_noargs
- ;;
-esac
-}
-#============================================================
-_test_help()
-{
- java -jar $OPENEJB_HOME/lib/openejb-core-*.jar test --help
-}
-#============================================================
-_test_noargs()
-{
- _test_intravm
- _test_server
- _test_http
-}
-#============================================================
-case $1 in
- "build")
- _command_build $@
- ;;
- "test")
- _command_test $@
- ;;
- "validate")
- _command_validate $@
- ;;
- "deploy")
- _command_deploy $@
- ;;
- "start")
- _command_start $@
- ;;
- "stop")
- _command_stop $@
- ;;
- "corba")
- _start_corba $@
- ;;
- "create_stubs")
- _create_stubs $@
- ;;
- "help")
- _command_help $@
- ;;
- "-help")
- _command_help $@
- ;;
- "--help")
- _command_help $@
- ;;
- *) _command_help $@
- ;;
-esac
-
-
-
+java -jar $OPENEJB_HOME/lib/[EMAIL PROTECTED]@.jar $*
\ No newline at end of file
Modified: trunk/openejb1/modules/core/src/bin/openejb.bat (2484 => 2485)
--- trunk/openejb1/modules/core/src/bin/openejb.bat 2006-02-22 21:00:42 UTC (rev 2484)
+++ trunk/openejb1/modules/core/src/bin/openejb.bat 2006-02-22 21:14:40 UTC (rev 2485)
@@ -26,109 +26,5 @@
goto EOF
:openejbHomeSet
-set OPTIONS=-Dopenejb.home=%OPENEJB_HOME%
-set P1=_%1
-set P2=_%2
-
-if /I %P1% EQU _TEST goto TEST
-if /I %P1% EQU _VALIDATE goto VALIDATE
-if /I %P1% EQU _DEPLOY goto DEPLOY
-if /I %P1% EQU _START goto START_SERVER
-if /I %P1% EQU _STOP goto STOP_SERVER
-
-echo Unknown option: %1
-goto HELP
-
-goto EOF
-REM================================================
-:HELP
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar
-
-goto EOF
-REM================================================
-:TEST
- if /I %P2% EQU _LOCAL goto TEST_INTRAVM
- if /I %P2% EQU _REMOTE goto TEST_SERVER
- if /I %P2% EQU _--HELP goto HELP_TEST
- if /I %P2% EQU _ goto TEST_NOARGS
-
- echo Unknown option: %2
- goto HELP_TEST
-
-goto EOF
-REM================================================
-:VALIDATE
- shift
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar validate %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto EOF
-REM================================================
-:DEPLOY
- shift
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar deploy %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto EOF
-REM================================================
-:START_SERVER
- shift
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar start %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto EOF
-REM================================================
-:STOP_SERVER
- shift
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar stop %1 %2 %3 %4 %5 %6 %7 %8 %9
-
-goto EOF
-REM================================================
-:TEST_NOARGS
- goto TEST_INTRAVM
-goto EOF
-REM================================================
-:TEST_INTRAVM
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar test local
-
-if /I %P2% EQU _ goto TEST_SERVER
-goto EOF
-REM================================================
-:TEST_SERVER
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar test remote
-
-goto EOF
-REM================================================
-:HELP_TEST
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar test --help
-
-goto EOF
-REM================================================
-:HELP_DEPLOY
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar deploy --help
-
-goto EOF
-REM================================================
-:HELP_VALIDATE
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar validate --help
-
-goto EOF
-REM================================================
-:HELP_START
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar start --help
-
-goto EOF
-REM================================================
-:HELP_STOP
-
- java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar stop --help
-
-goto EOF
-
-:EOF
-ENDLOCAL
+java -jar %OPENEJB_HOME%/lib/[EMAIL PROTECTED]@.jar %*
\ No newline at end of file
Modified: trunk/openejb1/modules/core/src/java/org/openejb/cli/Main.java (2484 => 2485)
--- trunk/openejb1/modules/core/src/java/org/openejb/cli/Main.java 2006-02-22 21:00:42 UTC (rev 2484)
+++ trunk/openejb1/modules/core/src/java/org/openejb/cli/Main.java 2006-02-22 21:14:40 UTC (rev 2485)
@@ -7,6 +7,7 @@
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
@@ -69,6 +70,21 @@
}
public static void main(String[] args) {
+ ArrayList argsList = new ArrayList();
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].indexOf("-D") == -1) {
+ argsList.add(args[i]);
+ } else {
+ String prop = args[i].substring(args[i].indexOf("-D") + 2, args[i].indexOf("="));
+ String val = args[i].substring(args[i].indexOf("=") + 1);
+
+ System.setProperty(prop, val);
+ }
+ }
+
+ args = (String[])argsList.toArray(new String[argsList.size()]);
+
init();
if (args.length > 0) {
@@ -81,11 +97,22 @@
} else {
String mainClass = null;
Class clazz = null;
+ boolean help = false;
- try {
- props = finder.doFindCommandProperies(args[0]);
- } catch (IOException e1) {
- e1.printStackTrace();
+ if (args[0].equals("help")) {
+ if (args.length < 2) {
+ printAvailableCommands();
+ }
+
+ try {
+ props = finder.doFindCommandProperies(args[1]);
+ } catch (IOException e1) {
+ System.out.println("Unavailable command: " + args[1]);
+
+ printAvailableCommands();
+ }
+
+ help = true;
}
if (props != null) {
@@ -108,18 +135,24 @@
e.printStackTrace();
}
- String[] trimmedArgs = null;
+ argsList = new ArrayList();
+ int startPoint = 1;
- if (args.length > 1) {
- trimmedArgs = new String[args.length - 1];
+ if (help) {
+ startPoint = 2;
- System.arraycopy(args, 1, trimmedArgs, 0, args.length - 1);
- } else {
- trimmedArgs = new String[0];
+ argsList.add("--help");
}
+
+ for (int i = startPoint; i < args.length; i++) {
+ argsList.add(args[i]);
+ }
+
+ args = (String[])argsList.toArray(new String[argsList.size()]);
+
try {
- mainMethod.invoke(clazz, new Object[] { trimmedArgs });
+ mainMethod.invoke(clazz, new Object[] { args });
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
@@ -176,5 +209,7 @@
System.out.println("For updates and additional information, visit");
System.out.println("http://www.openejb.org\n");
System.out.println("Bug Reports to <[email protected]>");
+
+ System.exit(1);
}
}
\ No newline at end of file