@ECHO off
rem
rem Windows launch script for the OpenSPML Browser
rem

rem Flag for testing in a Lighthouse environment
rem set LIGHTHOUSE=true

set JAVA=java.exe
if "%JAVA_HOME%" == "" goto :nojavahome
set JAVA=%JAVA_HOME%\bin\java.exe

:nojavahome
rem echo Using %JAVA%

rem set up the Java classpath
rem We need openspml.jar, soap.jar, xerces.jar, and j2ee.jar
rem We need j2ee.jar only for some javax.mail inside SOAPClient,
rem would be nice to remove this dependency.
rem 
rem For convenience the toolkit will come bundled with these jars
rem (though perhaps not j2ee.jar for licensing reasons)
rem If you want to use different versions, set the  appropriate 
rem variables below.  Unless you set all of these variables,
rem OPENSPML_HOME must be set to the installation directory.

if NOT "%OPENSPML_HOME%" == "" goto :homeset
echo WARNING: OPENSPML_HOME is not set
set OPENSPML_HOME=.
:homeset
rem echo OPENSPML_HOME=%OPENSPML_HOME%

set OPENSPML=
set SOAP=
set XERCES=
set JAXP=
set J2EE=

if NOT "%OPENSPML%" == "" goto :spmlset
set OPENSPML=%OPENSPML_HOME%/lib/openspml.jar
:spmlset

if NOT "%SOAP%" == "" goto :soapset
set SOAP=%OPENSPML_HOME%/lib/soap.jar
:soapset

if NOT "%XERCES%" == "" goto :xercesset
set XERCES=%OPENSPML_HOME%/lib/xercesImpl.jar
:xercesset

if NOT "%JAXP%" == "" goto :jaxpset
set JAXP=%OPENSPML_HOME%/lib/xmlParserAPIs.jar
:jaxpset

if NOT "%J2EE%" == "" goto :j2eeset
set J2EE=%OPENSPML_HOME%/lib/j2ee.jar
:j2eeset

rem Debug class path if you are developing
if "%LIGHTHOUSE%" == "" goto :nolighthouse
set CLASSES=%WSHOME%/WEB-INF/classes
set FLAGS=-Dspml.lighthouse=true
:nolighthouse

set CLASSPATH=%OPENSPML%;%SOAP%;%JAXP%;%XERCES%;%J2EE%
if "%CLASSES%" == "" goto :nodebug
set CLASSPATH=%CLASSES%;%CLASSPATH%
:nodebug

rem default file paths to the current working directory
set FLAGS=%FLAGS% -Duser.dir=.

echo CLASSPATH=%CLASSPATH%
rem echo FLAGS=%FLAGS%

set CLASS=org.openspml.browser.Browser

%JAVA% %FLAGS% %CLASS% %1 %2 %3 %4 %5 %6 %7 %8 %9

:endscript
