@echo on @REM -- Usage -- @if not "%2"=="" goto begin @echo Usage: build group example [-ms] @echo where "group" is the example group and @echo where "example" is the example directory, and @echo where "-ms" builds under Microsoft SDK for Java: @echo build basic beanManaged @echo build sequence oracle -ms @echo The EJBean will be saved in ejb_{group}_{example}.jar @echo You must run the setEnv script before using this script. @goto end :begin @echo. @echo ========= Start of building %1\%2 EJBean example ========= @echo. @setlocal set JAVA=java set JAVAC=javac if "%3"=="-ms" set JAVA=jview if "%3"=="-ms" set JAVAC=jvc set JAR=ejb_%1_%2.jar set DIRECTORY=%1\%2 set EJB_DIRECTORY=examples\ejb\%DIRECTORY% set TEMP=..\..\temp set EJB_TEMP=%TEMP%\%EJB_DIRECTORY% set EJB_CLIENT_CLASSES=%CLIENT_CLASSES%\%EJB_DIRECTORY% set EJB_SERVLET_CLASSES=%SERVLET_CLASSES%\%EJB_DIRECTORY% set CLASSPATH=%CLASSPATH%;%TEMP% :check1 @REM Building is dependent on the setEnv command: @if defined CLIENT_CLASSES goto check2 @echo. @echo Building the examples is dependent on setting certain variables @echo in your environment. Please run the setEnv.cmd script @echo (found in the \weblogic directory) before running this script. @goto finish :check2 @REM Building extensions is dependent on basic\containerManaged bean: @if not %1% == extensions goto check3 @if exist ..\..\myserver\ejb_basic_containerManaged.jar goto build @echo. @echo Building the extensions examples is dependent on the @echo basic\containerManaged example having been built first. Please @echo build the basic\containerManaged example ("build basic containerManaged") @echo before building either of the extensions examples. @goto finish :check3 @REM Building subclass\child bean is dependent on subclass\parent bean: @if not %2% == child goto build set CLASSPATH=%CLASSPATH%;..\..\myserver\ejb_subclass_parent.jar @if exist ..\..\myserver\ejb_subclass_parent.jar goto build @echo. @echo Building the subclass child example is dependent on the @echo subclass\parent example having been built first. Please @echo build the subclass\parent example ("build subclass parent") @echo before building the subclass\child example. @goto finish :build @REM Step 1: create directories if not exist %TEMP%\nul mkdir %TEMP% if not exist %EJB_CLIENT_CLASSES%\nul mkdir %EJB_CLIENT_CLASSES% if not exist %SERVLET_CLASSES%\nul mkdir %SERVLET_CLASSES% @REM Step 2: Compile classes %JAVAC% -d %TEMP% %DIRECTORY%\*.java @if errorlevel 1 goto error @REM Step 3: Copy classes to the clientclasses and servletclasses directories xcopy %EJB_TEMP% %EJB_CLIENT_CLASSES% /i xcopy %EJB_TEMP%\*Servlet.class %EJB_SERVLET_CLASSES% /i @if errorlevel 1 goto error @REM Step 4: Delete the Client code from the temp directory @REM and the Bean or Servlet code from the client directory del /q %EJB_TEMP%\*Client*.class del /q %EJB_TEMP%\*Servlet.class del /q %EJB_CLIENT_CLASSES%\*Bean*.class del /q %EJB_CLIENT_CLASSES%\*Servlet.class @REM Step 5: Create a .ser file from the deployment descriptor %JAVA% weblogic.ejb.utils.DDCreator -d %EJB_TEMP% -outputfile DD.ser %DIRECTORY%\DeploymentDescriptor.txt @if errorlevel 1 goto error @REM Step 6: Run ejbc on the DD.ser file, creating generated files %JAVA% weblogic.ejbc -compiler %JAVAC%.exe -d %TEMP% %EJB_TEMP%\DD.ser @if errorlevel 1 goto error pushd %TEMP% @REM Step 7: Jar the EJBean using the manifest file @if %2% == child goto subclass jar cmf ..\%EJB_DIRECTORY%\manifest ..\myserver\%JAR% %EJB_DIRECTORY% @if errorlevel 1 goto error goto cleanup :subclass @REM If building the subclass child jar, need to combine with parent jar: @if not exist ..\myserver\ejb_subclass_parent.jar goto cleanup jar xf ..\myserver\ejb_subclass_parent.jar jar cmf ..\%EJB_DIRECTORY%\manifest ..\myserver\ejb_subclass.jar examples\ejb\subclass del /q ..\myserver\ejb_subclass_*.jar :cleanup @REM Step 8: Remove the temp directory popd rmdir /s /q %TEMP% @if errorlevel 1 goto error @echo. @echo The EJBean has been saved in @echo. @echo %WL_HOME%\myserver\%JAR% @echo. @if "%1"=="-ms" goto msnote @echo To deploy the EJBean, either use the hot deploy feature of @echo the WebLogic Console to deploy the EJBean or add to the @echo "weblogic.ejb.deploy" property in the "weblogic.properties" @echo file an entry to deploy the .jar. @echo. @goto clientnote :msnote @if not "%1"=="-ms" goto clientnote @echo Running under the Microsoft SDK for Java, deploy the EJBean @echo by adding to the "weblogic.ejb.deploy" property in the @echo "weblogic.properties" file an entry to deploy the .jar. @echo. @echo You'll also need to add the path to the .jar to the CLASSPATH @echo for your Server. @echo. :clientnote @echo To run the client, follow the instructions in the @echo documentation for the example. @goto finish :error @REM return to starting directory popd @echo. @echo An error has occurred. Error level: %errorlevel% @echo. @echo You should delete any generated files and directories @echo (such as temp) before running the script again. :finish @echo. @echo ========= End of building %1\%2 EJBean example =========== @echo. :end @endlocal