From 5c8cf96b4dad3a63df82bb5e282181517544f261 Mon Sep 17 00:00:00 2001 From: Marnie McCormack Date: Tue, 17 Jun 2008 14:53:23 +0000 Subject: QPID-168 Applying an amended version of Suran's patch for this JIRA, expanding the .bat file's functionality to be closer to the bash scripts git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@668692 13f79535-47bb-0310-9956-ffa450edef68 --- java/broker/bin/qpid-server.bat | 151 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 146 insertions(+), 5 deletions(-) (limited to 'java') diff --git a/java/broker/bin/qpid-server.bat b/java/broker/bin/qpid-server.bat index a99022cd2d..80868998f4 100644 --- a/java/broker/bin/qpid-server.bat +++ b/java/broker/bin/qpid-server.bat @@ -17,7 +17,7 @@ @REM under the License. @REM -echo off +@echo off REM Script to run the Qpid Java Broker rem Guess QPID_HOME if not defined @@ -36,19 +36,157 @@ echo This environment variable is needed to run this program goto end :okHome +REM set QPID_WORK if not set +if not "%QPID_WORK%" == "" goto okQpidWork +if "%HOME%" == "" goto noHome +set QPID_WOKR=%HOME% +goto okQpidWork + +:noHome +set QPID_WORK=c:\Temp +if not exist %QPID_WORK% md %QPID_WORK% +:okQpidWork + if not "%JAVA_HOME%" == "" goto gotJavaHome echo The JAVA_HOME environment variable is not defined echo This environment variable is needed to run this program -goto exit +goto end :gotJavaHome if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome goto okJavaHome :noJavaHome echo The JAVA_HOME environment variable is not defined correctly echo This environment variable is needed to run this program. -goto exit +goto end :okJavaHome +REM set loggin level if not set +if "%AMQJ_LOGGING_LEVEL%" == "" set AMQJ_LOGGING_LEVEL=info + +REM Set the default system properties that we'll use now that they have +REM all been initialised +set SYSTEM_PROPS=-Damqj.logging.level=%AMQJ_LOGGING_LEVEL% -DQPID_HOME=%QPID_HOME% -DQPID_WORK=%QPID_WORK% + +if "%EXTERNAL_CLASSPATH%" == "" set EXTERNAL_CLASSPATH=%CLASSPATH% + +REM Use QPID_CLASSPATH if set +if "%QPID_CLASSPATH%" == "" goto noQpidClasspath +set CLASSPATH=%QPID_CLASSPATH% +echo Using CLASSPATH: %CLASSPATH% +goto afterQpidClasspath + +:noQpidClasspath +echo Warning: Qpid classpath not set. CLASSPATH set to %QPID_HOME%\lib\qpid-incubating.jar +set CLASSPATH=%QPID_HOME%\lib\qpid-incubating.jar +:afterQpidClasspath + +REM start parsing -run arguments +if "%1" == "" goto endRunArgs +:runLoop +set var=%1 +if "%var:~0,5%" == "-run:" goto runFound +:beforeRunShift +shift +if not "%1"=="" goto runLoop +goto endRunArgs + +:runFound +if "%var%" == "-run:debug" goto runDebug +if "%var%" == "-run:jpda" goto runJdpa +if "%var:~0,24%" == "-run:external-classpath-" goto runExternalClasspath +if "%var%" == "-run:print-classpath" goto runPrintCP +if "%var%" == "-run:help" goto runHelp +echo "unrecognized -run option '%var%'. For using external classpaths use -run:external-classpath-option" +goto end + +:runDebug +REM USAGE: print the classpath and command before running it +set debug=true +goto beforeRunShift + +:runJdpa +REM USAGE: adds debugging options to the java command, use +REM USAGE: JDPA_TRANSPORT and JPDA_ADDRESS to customize the debugging +REM USAGE: behavior and use JPDA_OPTS to override it entirely +if "%JPDA_OPTS%" == "" goto beforeRunShift +if "%JPDA_TRANSPORT%" == "" set JPDA_TRANSPORT=-dt_socket +if "%JPDA_ADDRESS%" == "" set JPDA_ADDRESS=8000 +set JPDA_OPTS="-Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=n" +set QPID_OPTS="%QPID_OPTS% %JPDA_OPTS%" +goto beforeRunShift + +:runExternalClasspath +echo Using external classpath %var% +REM USAGE: Format is -run:external-classpath-first/last/ignore/only as equals special in DOS +REM USAGE: controls how the CLASSPATH environment variable is used by +REM USAGE: this script, value can be one of ignore (the default), first, +REM USAGE: last, and only +if "%var%" == "-run:external-classpath-ignore" goto beforeRunShift +if "%var%" == "-run:external-classpath-first" goto extCPFirst +if "%var%" == "-run:external-classpath-last" goto extCPLast +if "%var%" == "-run:external-classpath-only" goto extCPOnly +echo Invalid value provided for external classpath. +goto end + +:extCPFirst +set CLASSPATH=%EXTERNAL_CLASSPATH%;%CLASSPATH% +goto beforeRunShift + +:extCPLast +set CLASSPATH=%CLASSPATH%;%EXTERNAL_CLASSPATH% +goto beforeRunShift + +:extCPonly +set CLASSPATH=%EXTERNAL_CLASSPATH% +goto beforeRunShift + +:runPrintCP +REM USAGE: print the classpath +echo %CLASSPATH% +goto beforeRunShift + +:runHelp +REM USAGE: print this message +echo ------------------------------------------------------------------------------------------- +echo -run:option where option can be the following. +echo debug : Prints classpath and command before running it +echo jpda : Adds remote debugging info using JPDA_OPTS. Use JPDA_TRANSPORT and JPDA_ADDRESS to +echo customize, JPDA_OPTS to override +echo external-classpath : Valid values are: ignore, first, last and only. +echo print-classpath : Prints classpath before running command +echo help : Prints this message +echo -------------------------------------------------------------------------------------------- +goto end + +REM end parsing -run arguments +:endRunArgs + +set JAVA_VM=-server +set JAVA_MEM=-Xmx1024m +set JAVA_GC=-XX:+UseConcMarkSweepGC +rem removing the following vm arg from JAVA_GC as it is supported on ly in Java 1.6 +rem -XX:+HeapDumpOnOutOfMemoryError" + +REM Use QPID_JAVA_GC if set +if "%QPID_JAVA_GC%" == "" goto noQpidJavaGC +set JAVA_GC=%QPID_JAVA_GC% +echo Using QPID_JAVA_GC setting: %QPID_JAVA_GC% +goto afteQpidJavaGC + +:noQPidJavaGC +echo Info: QPID_JAVA_GC not set. Defaulting to JAVA_GC %JAVA_GC% +:afterQpidJavaGC + +REM Use QPID_JAVA_MEM if set +if "%QPID_JAVA_MEM%" == "" goto noQpidJavaMem +set JAVA_MEM=%QPID_JAVA_MEM% +echo Using QPID_JAVA_MEM setting: %QPID_JAVA_MEM% +goto afterQpidJavaMem + +:noQpidJavaMem +echo Info: QPID_JAVA_MEM not set. Defaulting to JAVA_MEM %JAVA_MEM% +:after QpidJavaMem + rem Slurp the command line arguments. This loop allows for an unlimited number rem of agruments (up to the command line limit, anyway). set QPID_ARGS=%1 @@ -63,8 +201,11 @@ goto loop rem QPID_OPTS intended to hold any -D props for use rem user must enclose any value for QPID_OPTS in double quotes :runCommand -set LAUNCH_JAR=%QPID_HOME%\lib\qpid-incubating.jar set MODULE_JARS=%QPID_MODULE_JARS% -"%JAVA_HOME%\bin\java" -server -Xmx1024m %QPID_OPTS% -DQPID_HOME="%QPID_HOME%" -cp "%LAUNCH_JAR%;%MODULE_JARS%" org.apache.qpid.server.Main %QPID_ARGS% +set COMMAND="%JAVA_HOME%\bin\java" %JAVA_VM% %JAVA_MEM% %JAVA_GC% %QPID_OPTS% %SYSTEM_PROPS% -cp "%CLASSPATH%;%MODULE_JARS%" org.apache.qpid.server.Main %QPID_ARGS% + +if "%debug%" == "true" echo %CLASSPATH%;%LAUNCH_JAR%;%MODULE_JARS% +if "%debug%" == "true" echo %COMMAND% +%COMMAND% :end -- cgit v1.2.1