@Echo Off
Rem Verify if JAVA_HOME is well defined
if ["%JAVA_HOME%"]==[""] goto setroot

set JAVA="%JAVA_HOME%\bin\java"

set JVM_ARGS=-Dfelix.system.properties=file:conf\system.properties
set JVM_ARGS=%JVM_ARGS% -Dfelix.config.properties=file:conf\config.properties
set JVM_ARGS=%JVM_ARGS% -Xms256m -Xmx1024m

set DEBUG_OPTS=

if [%1]==[]   goto no_arg

set ARGS=

:loop_on_args
if [%1]==[-debug]    goto debug_arg
set ARGS=%ARGS% %1

Rem goto next_arg

:debug_arg
shift
if not [%1]==[-p] goto debug_usage
shift
set DEBUG_PORT=%1
set DEBUG_SUSPEND=y
if not [%2]==[-s] goto set_debug_opts
shift
shift
set DEBUG_SUSPEND=%1

:set_debug_opts
echo Debug Info :
echo  listening on port : %DEBUG_PORT%
echo  suspend mode : %DEBUG_SUSPEND%
set DEBUG_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=%DEBUG_PORT%,suspend=%DEBUG_SUSPEND%

:no_arg
%JAVA% %JVM_ARGS% %DEBUG_OPTS% -jar felix.jar
goto :EOF

:setroot
echo JAVA_HOME not set.
goto :EOF

:usage
echo "jadenode -debug"
echo "Debug mode : jadenode -debug -p <debug-port> [-s <suspend:y/n>]"
goto :EOF

:debug_usage
echo -debug option parameters are : "-debug -p <debug-port> [-s <suspend:y/n>]"
goto :EOF
