Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 1 | @echo off |
| 2 | rem |
| 3 | rem |
| 4 | rem Licensed to the Apache Software Foundation (ASF) under one or more |
| 5 | rem contributor license agreements. See the NOTICE file distributed with |
| 6 | rem this work for additional information regarding copyright ownership. |
| 7 | rem The ASF licenses this file to You under the Apache License, Version 2.0 |
| 8 | rem (the "License"); you may not use this file except in compliance with |
| 9 | rem the License. You may obtain a copy of the License at |
| 10 | rem |
| 11 | rem http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | rem |
| 13 | rem Unless required by applicable law or agreed to in writing, software |
| 14 | rem distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | rem See the License for the specific language governing permissions and |
| 17 | rem limitations under the License. |
| 18 | rem |
| 19 | rem |
Guillaume Nodet | 1becb5b | 2009-05-04 07:56:47 +0000 | [diff] [blame] | 20 | rem $Id: karaf.bat 979 2005-11-30 22:50:55Z bsnyder $ |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 21 | rem |
| 22 | |
| 23 | if not "%ECHO%" == "" echo %ECHO% |
| 24 | |
| 25 | setlocal |
| 26 | set DIRNAME=%~dp0% |
| 27 | set PROGNAME=%~nx0% |
| 28 | set ARGS=%* |
| 29 | |
| 30 | title Karaf |
| 31 | |
| 32 | goto BEGIN |
| 33 | |
| 34 | :warn |
| 35 | echo %PROGNAME%: %* |
| 36 | goto :EOF |
| 37 | |
| 38 | :BEGIN |
| 39 | |
| 40 | rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 41 | |
| 42 | if not "%KARAF_HOME%" == "" ( |
| 43 | call :warn Ignoring predefined value for KARAF_HOME |
| 44 | ) |
| 45 | set KARAF_HOME=%DIRNAME%.. |
| 46 | if not exist "%KARAF_HOME%" ( |
| 47 | call :warn KARAF_HOME is not valid: %KARAF_HOME% |
| 48 | goto END |
| 49 | ) |
| 50 | |
| 51 | if not "%KARAF_BASE%" == "" ( |
| 52 | if not exist "%KARAF_BASE%" ( |
| 53 | call :warn KARAF_BASE is not valid: %KARAF_BASE% |
| 54 | goto END |
| 55 | ) |
| 56 | ) |
| 57 | if "%KARAF_BASE%" == "" ( |
| 58 | set KARAF_BASE=%KARAF_HOME% |
| 59 | ) |
| 60 | |
| 61 | set LOCAL_CLASSPATH=%CLASSPATH% |
| 62 | set DEFAULT_JAVA_OPTS=-server -Xmx512M -Dderby.system.home="%KARAF_BASE%\data\derby" -Dderby.storage.fileSyncTransactionLog=true -Dcom.sun.management.jmxremote |
| 63 | set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf |
| 64 | set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 |
| 65 | |
| 66 | if "%LOCAL_CLASSPATH%" == "" goto :KARAF_CLASSPATH_EMPTY |
| 67 | set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf |
| 68 | goto :KARAF_CLASSPATH_END |
| 69 | :KARAF_CLASSPATH_EMPTY |
| 70 | set CLASSPATH=%KARAF_BASE%\conf |
| 71 | :KARAF_CLASSPATH_END |
| 72 | |
| 73 | rem Setup Karaf Home |
| 74 | if exist "%KARAF_HOME%\conf\karaf-rc.cmd" call %KARAF_HOME%\conf\karaf-rc.cmd |
| 75 | if exist "%HOME%\karaf-rc.cmd" call %HOME%\karaf-rc.cmd |
| 76 | |
| 77 | rem Support for loading native libraries |
| 78 | set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib |
| 79 | |
| 80 | rem Setup the Java Virtual Machine |
| 81 | if not "%JAVA%" == "" goto :Check_JAVA_END |
| 82 | set JAVA=java |
| 83 | if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary |
| 84 | if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java |
| 85 | if not exist "%JAVA_HOME%" ( |
| 86 | call :warn JAVA_HOME is not valid: "%JAVA_HOME%" |
| 87 | goto END |
| 88 | ) |
| 89 | :Check_JAVA_END |
| 90 | |
| 91 | if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS% |
| 92 | |
| 93 | if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END |
| 94 | rem Use the defaults if JAVA_DEBUG_OPTS was not set |
| 95 | if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS% |
| 96 | |
| 97 | set "JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%" |
| 98 | call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS% |
| 99 | :KARAF_DEBUG_END |
| 100 | |
| 101 | if "%KARAF_PROFILER%" == "" goto :KARAF_PROFILER_END |
| 102 | set KARAF_PROFILER_SCRIPT=%KARAF_HOME%\conf\profiler\%KARAF_PROFILER%.cmd |
| 103 | |
| 104 | if exist "%KARAF_PROFILER_SCRIPT%" goto :KARAF_PROFILER_END |
| 105 | call :warn Missing configuration for profiler '%KARAF_PROFILER%': %KARAF_PROFILER_SCRIPT% |
| 106 | goto END |
| 107 | :KARAF_PROFILER_END |
| 108 | |
| 109 | rem Setup the classpath |
| 110 | pushd "%KARAF_HOME%\lib" |
| 111 | for %%G in (*.*) do call:APPEND_TO_CLASSPATH %%G |
| 112 | popd |
| 113 | goto CLASSPATH_END |
| 114 | |
| 115 | : APPEND_TO_CLASSPATH |
| 116 | set filename=%~1 |
| 117 | set suffix=%filename:~-4% |
| 118 | if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\%filename% |
| 119 | goto :EOF |
| 120 | |
| 121 | :CLASSPATH_END |
| 122 | |
| 123 | rem Execute the JVM or the load the profiler |
| 124 | if "%KARAF_PROFILER%" == "" goto :RUN |
| 125 | rem Execute the profiler if it has been configured |
| 126 | call :warn Loading profiler script: %KARAF_PROFILER_SCRIPT% |
| 127 | call %KARAF_PROFILER_SCRIPT% |
| 128 | |
| 129 | :RUN |
| 130 | SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=true |
Guillaume Nodet | a8163d2 | 2010-01-18 14:34:26 +0000 | [diff] [blame] | 131 | SET MAIN=org.apache.felix.karaf.main.Bootstrap |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 132 | SET SHIFT=false |
Guillaume Nodet | a8163d2 | 2010-01-18 14:34:26 +0000 | [diff] [blame] | 133 | if "%1" == "stop" goto :EXECUTE_STOP |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 134 | if "%1" == "console" goto :EXECUTE_CONSOLE |
| 135 | if "%1" == "server" goto :EXECUTE_SERVER |
| 136 | if "%1" == "client" goto :EXECUTE_CLIENT |
| 137 | goto :EXECUTE |
| 138 | |
Guillaume Nodet | a8163d2 | 2010-01-18 14:34:26 +0000 | [diff] [blame] | 139 | :EXECUTE_STOP |
| 140 | SET MAIN=org.apache.felix.karaf.main.Stop |
| 141 | SET SHIFT=true |
| 142 | goto :EXECUTE |
| 143 | |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 144 | :EXECUTE_CONSOLE |
| 145 | SET SHIFT=true |
| 146 | goto :EXECUTE |
| 147 | |
| 148 | :EXECUTE_SERVER |
Guillaume Nodet | 7f569f2 | 2009-08-07 10:02:36 +0000 | [diff] [blame] | 149 | SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 150 | SET SHIFT=true |
| 151 | goto :EXECUTE |
| 152 | |
| 153 | :EXECUTE_CLIENT |
Guillaume Nodet | 7f569f2 | 2009-08-07 10:02:36 +0000 | [diff] [blame] | 154 | SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 155 | SET SHIFT=true |
| 156 | goto :EXECUTE |
| 157 | |
| 158 | :EXECUTE |
| 159 | if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8 |
| 160 | if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8 |
| 161 | rem Execute the Java Virtual Machine |
Freeman Yue Fang | 10aaf3b | 2009-10-22 01:42:18 +0000 | [diff] [blame] | 162 | cd %KARAF_BASE% |
Guillaume Nodet | 44ef462 | 2009-10-16 16:07:12 +0000 | [diff] [blame] | 163 | "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dstorage.location="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" org.apache.felix.karaf.main.Bootstrap %ARGS% |
Chris Custine | 10fff85 | 2009-05-04 06:11:07 +0000 | [diff] [blame] | 164 | |
| 165 | rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 166 | |
| 167 | :END |
| 168 | |
| 169 | endlocal |
| 170 | |
| 171 | if not "%PAUSE%" == "" pause |
| 172 | |
| 173 | :END_NO_PAUSE |
| 174 | |