blob: 3745aadacc3b2a2796fabcce8877ad428104ed48 [file] [log] [blame]
Gert Vanthienenc4f3d352009-09-24 23:18:33 +00001@echo off
2rem
3rem
4rem Licensed to the Apache Software Foundation (ASF) under one or more
5rem contributor license agreements. See the NOTICE file distributed with
6rem this work for additional information regarding copyright ownership.
7rem The ASF licenses this file to You under the Apache License, Version 2.0
8rem (the "License"); you may not use this file except in compliance with
9rem the License. You may obtain a copy of the License at
10rem
11rem http://www.apache.org/licenses/LICENSE-2.0
12rem
13rem Unless required by applicable law or agreed to in writing, software
14rem distributed under the License is distributed on an "AS IS" BASIS,
15rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16rem See the License for the specific language governing permissions and
17rem limitations under the License.
18rem
19rem
20rem $Id: karaf.bat 979 2005-11-30 22:50:55Z bsnyder $
21rem
22
23if not "%ECHO%" == "" echo %ECHO%
24
25setlocal
26set DIRNAME=%~dp0%
27set PROGNAME=%~nx0%
28set ARGS=%*
29
30title Karaf
31
32goto BEGIN
33
34:warn
35 echo %PROGNAME%: %*
36goto :EOF
37
38:BEGIN
39
40rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
41
42if not "%KARAF_HOME%" == "" (
43 call :warn Ignoring predefined value for KARAF_HOME
44)
45set KARAF_HOME=%DIRNAME%..
46if not exist "%KARAF_HOME%" (
47 call :warn KARAF_HOME is not valid: %KARAF_HOME%
48 goto END
49)
50
51if not "%KARAF_BASE%" == "" (
52 if not exist "%KARAF_BASE%" (
53 call :warn KARAF_BASE is not valid: %KARAF_BASE%
54 goto END
55 )
56)
57if "%KARAF_BASE%" == "" (
58 set KARAF_BASE=%KARAF_HOME%
59)
60
61set LOCAL_CLASSPATH=%CLASSPATH%
62set DEFAULT_JAVA_OPTS=-server -Xmx512M -Dderby.system.home="%KARAF_BASE%\data\derby" -Dderby.storage.fileSyncTransactionLog=true -Dcom.sun.management.jmxremote
63set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
64set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
65
66if "%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
73rem Setup Karaf Home
74if exist "%KARAF_HOME%\conf\karaf-rc.cmd" call %KARAF_HOME%\conf\karaf-rc.cmd
75if exist "%HOME%\karaf-rc.cmd" call %HOME%\karaf-rc.cmd
76
77rem Support for loading native libraries
78set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
79
80rem Setup the Java Virtual Machine
81if 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
91if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
92
93if "%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
101if "%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
109rem Setup the classpath
110pushd "%KARAF_HOME%\lib"
111for %%G in (*.*) do call:APPEND_TO_CLASSPATH %%G
112popd
113goto CLASSPATH_END
114
115: APPEND_TO_CLASSPATH
116set filename=%~1
117set suffix=%filename:~-4%
118if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\%filename%
119goto :EOF
120
121:CLASSPATH_END
122
123rem Execute the JVM or the load the profiler
124if "%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
131 SET SHIFT=false
132 if "%1" == "console" goto :EXECUTE_CONSOLE
133 if "%1" == "server" goto :EXECUTE_SERVER
134 if "%1" == "client" goto :EXECUTE_CLIENT
135 goto :EXECUTE
136
137:EXECUTE_CONSOLE
138 SET SHIFT=true
139 goto :EXECUTE
140
141:EXECUTE_SERVER
142 SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true
143 SET SHIFT=true
144 goto :EXECUTE
145
146:EXECUTE_CLIENT
147 SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false
148 SET SHIFT=true
149 goto :EXECUTE
150
151:EXECUTE
152 if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
153 if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
154 rem Execute the Java Virtual Machine
155 "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" -jar "%KARAF_HOME%\lib\karaf-client.jar" "osgi:shutdown"
156
157rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
158
159:END
160
161endlocal
162
163if not "%PAUSE%" == "" pause
164
165:END_NO_PAUSE
166