Skip navigation.
Downloads | Product Documentation | Support

Beehive Integration in WebLogic Server 9.1

# Build Script Sample - Create Web Service That Uses a Service Control

>     <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>       !!! This build script takes you step by step through creating
>       !!! a web service application that uses a service control.
>       !!! It starts with a wsdl and a client jws.
>       !!! There are three important directories invovled:
>       !!!   src.dir   - which is where the source wsdl and jws are located
>       !!!   build.dir - which is used to create build artifacts
>       !!!   deploy.dir - which is the directory that you want to deploy
>       !!!                the ear into.
>       !!!
>       !!! The build will take place in stages. Each step will be
>       !!! contributing to an enterprise application directory
>       !!! within the build.dir.
>       !!! At the end of the build the entire application will be
>       !!! built and put into an ear file in the ${build.dir}/deploy
>       !!! directory.
>       !!!
>       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>     -->

>     <project name="serviceControlBuildExample" default="build">

>         <property environment="env" />
>         <property name="dev.home" value="${env.DEV_ROOT}" />
>         <property name="weblogic.home" value="${env.WL_HOME}" />
>         <property name="jdk.home" value="${env.JAVA_HOME}" />
>         <property name="app.name" value="${ant.project.name}" />
>         <import file="${dev.home}/wlw/controls/controls-imports.xml" />
>         <import file="${dev.home}/wlw/netui/netui-imports.xml" />
>         <import file="${dev.home}/common/beehive/beehive-imports.xml" />
>         <import file="${weblogic.beehive.home}/ant/weblogic-beehive-imports.xml" />
>         <import file="${weblogic.beehive.home}/ant/weblogic-beehive-tools.xml" />
>         <import file="${weblogic.beehive.home}/ant/weblogic-beehive-buildmodules.xml" />

>         <!-- this is the source directory -->
>         <property name="src.dir" location="./src"/>

>         <!-- this is where things are built into. the ear will wind up in the deploy subdirectory -->
>         <property name="build.dir" location="C:/tmp"/>

>         <!-- this is the domain that you wish to deploy your application to -->
>         <property name="deploy.dir" location="${weblogic.home}/test/scexample/${app.name}/app"/>

>         <!-- The ent.app.dir is where the enterprise application is built into.
>           -->
>         <property name="ent.app.dir" location="${build.dir}/${app.name}"/>

>         <!-- this is a temporary directory used frequently for disposable work -->
>         <property name="temp.dir" location="${build.dir}/work"/>
>         <delete dir="${temp.dir}"/>

>         <!-- Setup classpath -->
>         <property name="temp.lib.dir" value="${build.dir}/templibdir"/>
>         <mkdir dir="${temp.lib.dir}"/>
>         <taskdef name="libclasspath" classname="weblogic.ant.taskdefs.build.LibClasspathTask" />
>         <property name="common.dir" location="${dev.home}/wlw/test/drt/domain/common" />
>         <property name="deployable.lib.dir" location="${weblogic.home}/common/deployable-libraries" />
>         <libclasspath tmpdir="${temp.lib.dir}" basedir="${common.dir}" classpathproperty="app.lib.classpath">
>                 <librarydir dir="${deployable.lib.dir}" />
>         </libclasspath>
>         <libclasspath tmpdir="${temp.lib.dir}" basedir="${common.dir}/testjpf" classpathproperty="web.lib.classpath">
>                 <librarydir dir="${deployable.lib.dir}" />
>         </libclasspath>
>         <path id="classpath">
>                 <pathelement path="${app.lib.classpath}" />
>                 <pathelement path="${web.lib.classpath}" />
>                 <pathelement location="${dev.home}/external/junit/junit.jar" />
>                 <pathelement location="${weblogic.home}/server/lib/weblogic.jar" />
>                 <fileset dir="${ent.app.dir}/APP-INF/lib" includes="**/*.jar" />
>                 <pathelement path="${ent.app.dir}/APP-INF/classes" />
>         </path>

>         <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>          !!! This is the primary build script which describes step by step
>          !!! how to build a jws application that uses a service control.
>          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>          -->
>         <target name="build">

>             <!-- let's initialize the EAR directiry by creating it
>               !! and seeding it with some initial descriptor files
>               !! that provide support for controls
>               -->
>             <mkdir dir="${ent.app.dir}"/>
>             <mkdir dir="${ent.app.dir}/APP-INF/lib"/>
>             <mkdir dir="${ent.app.dir}/APP-INF/classes"/>
>             <copy todir="${ent.app.dir}">
>                     <fileset dir="${src.dir}">
>                             <include name="META-INF/*.xml" />
>                     </fileset>
>             </copy>

>             <mkdir dir="${temp.dir}"/>

>             <!--
>             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>             !!!  BUILDING THE SERVICE CONTROL
>             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>              -->

>             <!-- first we need to build the types jar file. This will get
>              !!! generated right into the ent.app.dir where our enterprise
>              !!! application will be created. All you need is a wsdl!
>              !!! The output from this step is a types jar file placed
>              !!! in he /APP-INF/lib of the ear.
>             -->
>             <build-type-library
>                     wsdl="${src.dir}/wsdl/HelloTypesService.wsdl"
>                     tempdir="${temp.dir}"
>                     typefamily="tylar"
>                     destdir="${ent.app.dir}/APP-INF/lib"
>                     wsdlname="HelloTypesService"
>                     wsdlservicename="HelloTypesService"
>                />
>             <delete dir="${temp.dir}"/>

>             <!-- next we need to build the actual service control jcx
>              !!! which will be generated into a work directory
>              !!! along with the wsdl.
>              !!! The output from this step is the actual service control
>              !!! extension (jcx) file placed in the "gensrc" directory.
>              !!! In this case it is the hellotest.HelloTypesServiceControl.jcx
>              !!! The WSDL is also placed in the same directory with the
>              !!! service control extension.
>             -->
>             <property name="gen.src.dir" location="${build.dir}/gensrc"/>
>             <mkdir dir="${gen.src.dir}"/>
>             <generate-webservice-control
>                     wsdl="${src.dir}/wsdl/HelloTypesService.wsdl"
>                     wsdlservicename="HelloTypesService"
>                     destdir="${gen.src.dir}"
>                     appdir="${ent.app.dir}"
>                     servicecontrolname="HelloTypesServiceControl"
>                     package="hellotest"
>                     typefamily="tylar"
>                     classpathref="classpath"
>              />

>             <!-- next we will build the control support classes
>              !!! into the APP-INF/classes directory so
>              !!! that all apps can take advantage of it.
>              !!! This could be built into its own jar or
>              !!! into the client too.
>              !!! The following files are created and placed in APP-INF/classes
>              !!!    HelloTypesServiceControl.class (interface)
>              !!!    HelloTypesServiceControlBean.class (impl)
>              !!!    HelloTypesServiceControlBean.class.manifest
>              !!!    HelloTypesServiceControlBeanBeanInfo.class
>              !!! These are all standard controls files
>             -->
>             <mkdir dir="${temp.dir}"/>
>             <mkdir dir="${ent.app.dir}/APP-INF/classes"/>
>             <build-controls srcdir="${gen.src.dir}"
>                             destdir="${ent.app.dir}/APP-INF/classes"
>                             tempdir="${temp.dir}"
>                             classpathref="classpath" />

>             <!--
>                  Important thing to remember is to move
>                  the wsdl into the same directory as
>                  the service control class.
>             -->
>             <copy todir="${ent.app.dir}/APP-INF/classes">
>                     <fileset dir="${gen.src.dir}" includes="**/*.wsdl" />
>             </copy>
>             <delete dir="${temp.dir}"/>

>             <mkdir dir="${build.dir}/module"/>
>             <mkdir dir="${build.dir}/aptgen"/>
>             <mkdir dir="${temp.dir}"/>

>             <!--
>             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>             !!!  BUILDING THE CLIENT THAT USES A SERVICE CONTROL
>             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>              -->

>             <!--  The first step is to run apt against the source code to
>               !!! process the annotations.
>               !!! The output from this step is source code placed in
>               !!! the gendir (aptgen) directory which consists of
>               !!! the HelloTest.jws converted to HelloTest.java
>               !!! and a HelloTestClientInitializer.java to help initialize
>               !!! the service control.
>               !!! apt also compiles these classes into the destdir...
>               !!! which in this case is the beginnings of our ejb jar
>               !!! The following files are created:
>               !!!   HelloTest.class (from source in gendir)
>               !!!   HelloTestClientInitializer.class (from source in gendir)
>               !!!   HelloTest.controls.properties file to help associate the
>               !!!           service control with the client
>               -->
>             <taskdef name="apt"
>                 classname="org.apache.beehive.controls.runtime.generator.AptTask"
>                 classpathref="apt.task.classpath"
>                 onerror="fail"/>

>             <apt srcdir="${src.dir}"
>                 destdir="${build.dir}/module"
>                 gendir="${build.dir}/aptgen"
>                 classpathref="classpath"
>                 srcExtensions="*.jws"
>                 />

>             <!--  The second step is to build the initial version of
>               !!! the jws ejb jar. You do this by running jwsc against
>               !!! the code generated by apt in the aptgen dir.
>               !!! The output from this step is a jar file called
>               !!! HelloTest.jar in the dest dir (ent.app.dir)
>               !!! and the META-INF/application.xml gets updated
>               !!! too with a reference to the ejb.
>               !!! A lot of different things are generated here
>               !!! to support the
>              -->
>             <taskdef name="jwsc"
>                 classpath="${weblogic.home}/server/lib/weblogic.jar"
>                 classname="weblogic.wsee.tools.anttasks.JwscTask"
>                 onerror="report" />

>             <jwsc srcdir="${build.dir}/aptgen"
>               destdir="${ent.app.dir}"
>               classpathref="classpath"
>               debug="on" keepGenerated="true">
>               <jws file="hellotest/HelloTest.java"/>
>             </jwsc>

>             <!--  The third step is to run controls assembly
>               !!! on the ejb application to provide the remaining
>               !!! information needed by the service control.
>               !!! To do this we unjar the HelloTest.jar into
>               !!! the "module" directory we created above.
>               !!! Then we run the assemble-controls task,
>               !!! compile the new stuff that gets generated
>               !!! into the module dir.
>               !!! and then we re-jar the module directory back
>               !!! into the ent.app.dir (ear).
>               !!! The following artifcats are generated by assembly and
>               !!! put in the module root:
>               !!!    hellotest/HelloTypesServiceControlJaxRpcMap.xml - 109 bindings file
>               !!!    hellotest/HelloTypesServiceControlServiceClassMemento.ser -     runtime info used by the service control
>               !!!
>               !!! The ejb-jar.xml is updated to contain <service-ref tags that
>               !!! provide a service reference to the jax-rpc stub with for the
>               !!! service control.
>               !!!
>               !!! In the destdir (tempdir) the HelloTypesServiceControlSEI.java file
>               !!! is created which provides the Service Endpoint Interface for JAX-RPC.
>               !!! This will be compiled next.
>               !!!
>              -->
>             <unjar src="${ent.app.dir}/hellotest/HelloTest.jar" dest="${build.dir}/module"/>
>             <assemble-controls
>                 moduledir="${build.dir}/module"
>                 destdir="${temp.dir}"
>                 classpathref="classpath"
>                 assemblerclass="org.apache.beehive.controls.runtime.assembly.EJBAssemblyContext$Factory"/>

>             <!-- we need to build the ServiceEndpointInterface -->
>             <javac srcdir="${temp.dir}" classpathRef="classpath"
>                 destdir="${ent.app.dir}/APP-INF/classes"
>                 includes="**" />

>             <!-- we can put the app module back together into a nice jar file -->
>             <jar jarfile="${ent.app.dir}/hellotest/HelloTest.jar" >
>                 <fileset dir="${build.dir}/module" />
>             </jar>
>             <delete dir="${temp.dir}"/>

>             <!-- The EAR is ready to be packed up...we put it in the deploy dir -->
>             <mkdir dir="${build.dir}/deploy" />
>             <jar jarfile="${build.dir}/deploy/${app.name}.ear" >
>                 <fileset dir="${ent.app.dir}" />
>             </jar>

>         </target>

>         <target name="deploy">
>             <echo message="Deploying application ${app.name}" />
>             <copy file="${build.dir}/deploy/${app.name}.ear" todir="${deploy.dir}" />
>             <wldeploy action="deploy" source="${deploy.dir}/${app.name}.ear" name="${app.name}" user="weblogic" password="weblogic" verbose="false" adminurl="t3://localhost:7001" debug="false" targets="cgServer" />
>         </target>

>         <target name="undeploy">
>             <fail message="The property app.name is not set." unless="app.name" />
>             <echo message="Undeploying application ${app.name}" />
>             <wldeploy action="undeploy" name="${app.name}" user="weblogic" password="weblogic" verbose="false" adminurl="t3://localhost:7001" debug="false" targets="cgServer" />
>         </target>

>         <target name="clean">
>           <delete dir="${build.dir}"/>
>         </target>

>     </project>