instance.bat 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. if not "%ECHO%" == "" echo %ECHO%
  20. setlocal
  21. set DIRNAME=%~dp0%
  22. set PROGNAME=%~nx0%
  23. set ARGS=%*
  24. rem Sourcing environment settings for karaf similar to tomcats setenv
  25. SET KARAF_SCRIPT="instance.bat"
  26. if exist "%DIRNAME%setenv.bat" (
  27. call "%DIRNAME%setenv.bat"
  28. )
  29. rem Check console window title. Set to Karaf by default
  30. if not "%KARAF_TITLE%" == "" (
  31. title %KARAF_TITLE%
  32. ) else (
  33. title Karaf
  34. )
  35. rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
  36. if "%JAVA_MIN_MEM%" == "" (
  37. set JAVA_MIN_MEM=128M
  38. )
  39. if "%JAVA_MAX_MEM%" == "" (
  40. set JAVA_MAX_MEM=512M
  41. )
  42. goto BEGIN
  43. :warn
  44. echo %PROGNAME%: %*
  45. goto :EOF
  46. :BEGIN
  47. rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  48. if not "%KARAF_HOME%" == "" (
  49. call :warn Ignoring predefined value for KARAF_HOME
  50. )
  51. set KARAF_HOME=%DIRNAME%..
  52. if not exist "%KARAF_HOME%" (
  53. call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
  54. goto END
  55. )
  56. if not "%KARAF_BASE%" == "" (
  57. if not exist "%KARAF_BASE%" (
  58. call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
  59. goto END
  60. )
  61. )
  62. if "%KARAF_BASE%" == "" (
  63. set "KARAF_BASE=%KARAF_HOME%"
  64. )
  65. if not "%KARAF_DATA%" == "" (
  66. if not exist "%KARAF_DATA%" (
  67. call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
  68. goto END
  69. )
  70. )
  71. if "%KARAF_DATA%" == "" (
  72. set "KARAF_DATA=%KARAF_BASE%\data"
  73. )
  74. if not "%KARAF_ETC%" == "" (
  75. if not exist "%KARAF_ETC%" (
  76. call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
  77. goto END
  78. )
  79. )
  80. if "%KARAF_ETC%" == "" (
  81. set "KARAF_ETC=%KARAF_BASE%\etc"
  82. )
  83. set DEFAULT_JAVA_OPTS=
  84. set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
  85. rem Support for loading native libraries
  86. set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
  87. rem Setup the Java Virtual Machine
  88. if not "%JAVA%" == "" goto :Check_JAVA_END
  89. set JAVA=java
  90. if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
  91. if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
  92. if not exist "%JAVA_HOME%" (
  93. call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
  94. goto END
  95. )
  96. :Check_JAVA_END
  97. if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
  98. if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
  99. set JAVA_OPTS="%JAVA_OPTS% %EXTRA_JAVA_OPTS%"
  100. :KARAF_EXTRA_JAVA_OPTS_END
  101. if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
  102. rem Use the defaults if JAVA_DEBUG_OPTS was not set
  103. if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
  104. set JAVA_OPTS="%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
  105. call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
  106. :KARAF_DEBUG_END
  107. rem Setup the classpath
  108. pushd "%KARAF_HOME%\lib"
  109. for %%G in (*.jar) do call:APPEND_TO_CLASSPATH %%G
  110. popd
  111. goto CLASSPATH_END
  112. : APPEND_TO_CLASSPATH
  113. set filename=%~1
  114. set suffix=%filename:~-4%
  115. if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\%filename%
  116. goto :EOF
  117. :CLASSPATH_END
  118. set CLASSPATH=%KARAF_HOME%\system\org\apache\karaf\instance\org.apache.karaf.instance.core\4.0.9\org.apache.karaf.instance.core-4.0.9.jar
  119. set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\apache\karaf\shell\org.apache.karaf.shell.core\4.0.9\org.apache.karaf.shell.core-4.0.9.jar
  120. set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\ops4j\pax\logging\pax-logging-api\1.8.5\pax-logging-api-1.8.5.jar
  121. set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\jline\jline\2.14.1\jline-2.14.1.jar
  122. :EXECUTE
  123. if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
  124. if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
  125. rem Execute the Java Virtual Machine
  126. "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.instances="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.etc="%KARAF_ETC%" -Djava.io.tmpdir="%KARAF_DATA%\tmp" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %KARAF_OPTS% org.apache.karaf.instance.main.Execute %ARGS%
  127. rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  128. :END
  129. endlocal