@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\websample
set CLASS_DIR=%JONAS_ROOT%\examples\classes
set JAR_DIR=%JONAS_ROOT%\ejbjars
set WEBAPPS=%JONAS_ROOT%\webapps

Rem compile bean classes and make the .jar file
cd %HERE%\beans\org\objectweb\secusb
javac -d %CLASS_DIR% *.java
md %CLASS_DIR%\META-INF
copy secusb.xml %CLASS_DIR%\META-INF\ejb-jar.xml
copy jonas-secusb.xml %CLASS_DIR%\META-INF\jonas-ejb-jar.xml
cd %CLASS_DIR%
jar cvf org\objectweb\secusb\secusb.jar META-INF\ejb-jar.xml META-INF\jonas-ejb-jar.xml org\objectweb\secusb\*.class
del META-INF\*.xml

Rem deploy the bean and install it
cd %HERE%
call %JONAS_ROOT%\bin\nt\GenIC.bat -d %CLASS_DIR% -keepgenerated -secpropag %CLASS_DIR%\org\objectweb\secusb\secusb.jar
copy %CLASS_DIR%\org\objectweb\secusb\secusb.jar %JAR_DIR%

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

Rem make the .war file
md %WEBAPPS%\websample
md %WEBAPPS%\websample\WEB-INF
md %WEBAPPS%\websample\WEB-INF\lib
md %WEBAPPS%\websample\WEB-INF\classes
md %WEBAPPS%\websample\WEB-INF\classes\org
md %WEBAPPS%\websample\WEB-INF\classes\org\objectweb
md %WEBAPPS%\websample\WEB-INF\classes\org\objectweb\websample
cd %CLASS_DIR%
copy org\objectweb\websample\*.class %WEBAPPS%\websample\WEB-INF\classes\org\objectweb\websample
cd %HERE%
copy etc\web.xml %WEBAPPS%\websample\WEB-INF
copy %JAR_DIR%\secusb.jar %WEBAPPS%\websample\WEB-INF\lib
cd web
xcopy /s * %WEBAPPS%\websample
cd %WEBAPPS%\websample
jar cvf ..\websample.war .

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

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

:End
cd %HERE%
