@echo off

cd $INSTALL_PATH\Scheduler

rem Action switch.
if "%1%" == "start" goto start
if "%1%" == "stop" goto stop
if "%1%" == "status" goto status

echo "Usage: %0 {start|stop|restart|status}"
goto end

:start
echo ============================
echo QueWeb.
echo Starting QueWeb Scheduler...
echo ============================

rem Set correct value to JBOSS_HOME
set JBOSS_HOME=$JBOSS_PATH
set QWLIB=$INSTALL_PATH\Scheduler

set CP=
set CP=%CP%;"%QWLIB%\castor-0.9.7-xml.zip"
set CP=%CP%;"%QWLIB%\jakarta-regexp-1.4.jar"
set CP=%CP%;"%QWLIB%\qwcore-ejb.jar"
set CP=%CP%;"%QWLIB%\qwoss-ejb.jar"
set CP=%CP%;"%JBOSS_HOME%\lib\commons-logging.jar"
set CP=%CP%;"%JBOSS_HOME%\lib\endorsed\xercesImpl.jar"
set CP=%CP%;"%JBOSS_HOME%\client\jbossall-client.jar"
set CP=%CP%;"%JBOSS_HOME%\client\javax.servlet.jar"
set CP=%CP%;"%JBOSS_HOME%\client\log4j.jar"
set CP=%CP%;"%JBOSS_HOME%\client\mail.jar"

set JAVA_OPTS=-Dqx.mode=prod
set JAVA_OPTS=%JAVA_OPTS% -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
set JAVA_OPTS=%JAVA_OPTS% -Djava.naming.provider.url=jnp://localhost:$JNDI_PORT
set JAVA_OPTS=%JAVA_OPTS% -Djava.naming.factory.url.pkgs=org.jboss.naming.client
set JAVA_OPTS=%JAVA_OPTS% -Dj2ee.clientName=qw-client

@if not exist log4j.properties copy log4j.properties.example log4j.properties

"$JDKPath\bin\java" %JAVA_OPTS% -classpath %CP% com.queplix.core.modules.services.ServiceRunner
echo Done
goto end

:stop
echo Scheduler stop is not implemented for JBoss on Windows
goto end

:status
echo Scheduler status check is not implemented for JBoss on Windows
goto end

:end
