@Echo off


Rem This script is the equivalent of "make install" in this directory.

Rem  Check environment variables:
if not exist %JONAS_ROOT%\bin\nt\config_env.bat goto SetRoot
call %JONAS_ROOT%\bin\nt\config_env.bat

set HERE=%JONAS_ROOT%\examples\alarm
set CLASS_DIR=%JONAS_ROOT%\examples\classes
set JAR_DIR=%JONAS_ROOT%\ejbjars
set WEBAPPS=%JONAS_ROOT%\webapps

Rem makes the classes directory
if not exist %CLASS_DIR%  md %CLASS_DIR%

Rem compile AlarmGenerator
cd %HERE%\client\org\objectweb\alarm
javac -d %CLASS_DIR% AlarmGenerator.java

Rem make alarm.jar (beans + alarm service)
cd %HERE%\beans\org\objectweb\alarm\beans
javac -d %CLASS_DIR% *.java
if not exist %CLASS_DIR%\META-INF  md %CLASS_DIR%\META-INF
copy alarm.xml %CLASS_DIR%\META-INF\ejb-jar.xml
copy jonas-alarm.xml %CLASS_DIR%\META-INF\jonas-ejb-jar.xml
cd %CLASS_DIR%
jar cvf org\objectweb\alarm\beans\alarm.jar META-INF\ejb-jar.xml META-INF\jonas-ejb-jar.xml org\objectweb\alarm\beans\*.class 
del META-INF\*.xml
cd %HERE%\beans\org\objectweb\alarm\beans
call %JONAS_ROOT%\bin\nt\GenIC.bat -d %CLASS_DIR% -keepgenerated %CLASS_DIR%\org\objectweb\alarm\beans\alarm.jar
copy %CLASS_DIR%\org\objectweb\alarm\beans\alarm.jar %JAR_DIR%

Rem compile servlet
cd %HERE%\src\org\objectweb\alarm
javac -d %CLASS_DIR% *.java

Rem make alarm.war (html, images, JSPs, web.xml)
md %WEBAPPS%\alarm
md %WEBAPPS%\alarm\WEB-INF
md %WEBAPPS%\alarm\WEB-INF\lib
md %WEBAPPS%\alarm\WEB-INF\classes
md %WEBAPPS%\alarm\WEB-INF\classes\org
md %WEBAPPS%\alarm\WEB-INF\classes\org\objectweb
md %WEBAPPS%\alarm\WEB-INF\classes\org\objectweb\alarm
copy %JAR_DIR%\alarm.jar %WEBAPPS%\alarm\WEB-INF\lib
cd %CLASS_DIR%
copy org\objectweb\alarm\*.class %WEBAPPS%\alarm\WEB-INF\classes\org\objectweb\alarm
cd %HERE%
copy etc\web.xml %WEBAPPS%\alarm\WEB-INF
cd web
xcopy /s * %WEBAPPS%\alarm
cd %WEBAPPS%\alarm
jar cvf ..\alarm.war .

@echo " install alarm.war"
@echo "rmdir /s /q <TOMCAT_HOME>\webapps\alarm"
@echo "copy %WEBAPPS%\alarm.war <TOMCAT_HOME>\webapps"
@echo "cd %HERE%"
@echo "copy apps-alarm.xml  <TOMCAT_HOME>\conf"
Goto End

:SetRoot
@echo "JONAS_ROOT must be set"
Goto End

:End
cd %HERE%
