|
At this point, let's create a build file, shown in Listing 7.2, that will take the implementation source file and produce all of the required files for our new bean. All of the work is accomplished with Ant tasks that use both XDoclet and Resin's XDoclet extensions.
Listing 7.2: Our Ant build file.
<project name="resincmp" default="all"> <property file="build.properties"/> <path > <pathelement path="${resinlib}/resin-ejb.jar" /> <pathelement path="${resinlib}/ejb.jar" /> <pathelement path="${xdocpath}" /> </path> <target name="clean"> <delete file="$ {webinf}/cmp-xdoclet.ejb" failonerror="false" /> <delete dir="${webinf}/classes" failonerror="false"/> </target> <target name="ejbdoclet" > <echo message="XDoc classpath = ${xdocpath)" /> <taskdef name="resingendd" classname="com.caucho.xdoclet.ResinEjbDocletTask" classpath="${xdocpath)" /> <resingendd ejbspec="2.0" sourcepath="${src}" ejbClassNameSuffix="Bean" mergedir="${src}" destdir="${src}" classpathref="resinclasspath" > <fileset dir="${src}"> <include name="${beans}" /> </fileset> <localinterface/> <localhomeinterface/> <remoteinterface/> <homeinterface/> <entitypk/> <deploymentdescriptor destdir="${webinf}" destinationFile="cmp-xdoclet.ejb" validatexml="true" /> </resingendd> </target> <target name="build" > <mkdir dir="${dest}" /> <javac srcdir="${src}" classpathref="resinclasspath" destdir="${dest}"/> </target> <target name="all" depends="clean,build,ejbdoclet" /> </project>
There are three primary targets for the build file: clean, build, and ejbdoclet. Most of the work is accomplished in ejbdoclet. Within this target, there is one primary task: resingendd. Within this task are several subtasks. The first, called localinterface, creates the local interface. The localhomeinterface sub-task, as you'd expect, creates the local home interface. Finally, the deploymentdescriptor subtask creates the deployment descriptor for our new bean. In most cases, we have to cut and paste the information in the generated deployment descriptor file into our current descriptor file.
You might have to change two primary paths—Resinlib and xdocpath—on your own system. Check the build.properties file and verify all paths before issuing the command
ant buildfile.xml
|