Part I Development Tasks and Tools
1. Setting Up a Development Environment
3. Using Ant with Enterprise Server
Subelements of sun-appserv-deploy
Attributes of sun-appserv-deploy
Examples of sun-appserv-deploy
Subelements of sun-appserv-undeploy
Attributes of sun-appserv-undeploy
Examples of sun-appserv-undeploy
Subelements of sun-appserv-instance
Attributes of sun-appserv-instance
Examples of sun-appserv-instance
The sun-appserv-component Task
Subelements of sun-appserv-component
Attributes of sun-appserv-component
Examples of sun-appserv-component
Subelements of sun-appserv-admin
Attributes of sun-appserv-admin
Attributes of sun-appserv-jspc
Attributes of sun-appserv-update
Part II Developing Applications and Application Components
7. Using the Java Persistence API
8. Developing Web Applications
9. Using Enterprise JavaBeans Technology
10. Using Container-Managed Persistence
13. Developing Lifecycle Listeners
Part III Using Services and APIs
14. Using the JDBC API for Database Access
15. Using the Transaction Service
16. Using the Java Naming and Directory Interface
To set up your Ant environment for using Enterprise Server Ant tasks, you can either define the ANT_OPTS environment variable or define a target. In both these cases, you must also set the classpath to point to the sun-appserv-ant.jar file.
To define the ANT_OPTS environment variable on UNIX systems, use the following commands, where ${ASINSTALLDIR} is an environment variable defined to point to the Enterprise Server installation directory.
export ANT_OPTS="-Djava.library.path${ASINSTALLDIR}/modules" export CLASSPATH=${CLASSPATH};${ASINSTALLDIR}/modules/sun-appserv-ant.jar
To define the ANT_OPTS environment variable on Windows systems, use the following commands, where %ASINSTALLDIR% is an environment variable defined to point to the Enterprise Server installation directory.
set ANT_OPTS="-Djava.library.path=%ASINSTALLDIR%\modules" set CLASSPATH=%CLASSPATH%;%ASINSTALLDIR%\modules\sun-appserv-ant.jar
The following target element defines the Enterprise Server Ant tasks and references the sun-appserv-ant.jar file. You can include this target in your build.xml file. The ${asinstalldir} in the classpath element refers to the Enterprise Server installation directory.
<target name="as-ant-init"> <taskdef name="sun-appserv-deploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask" /> <taskdef name="sun-appserv-undeploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask" /> <taskdef name="sun-appserv-component" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentTask" /> <taskdef name="sun-appserv-admin" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.AdminTask" /> <taskdef name="sun-appserv-jspc" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.SunJspc" /> <taskdef name="sun-appserv-update" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UpdateTask" /> <taskdef name="sun-appserv-instance" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.InstanceTask" /> <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" /> <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" /> <classpath path="${asinstalldir}/lib/sun-appserv-ant.jar" /> </target>
Targets that use the Enterprise Server Ant tasks then can use the as-ant-init target as a dependency. For example:
<target name="create-some-jdbc-resource" depends="as-ant-init"> ... </target>
Ant resolves properties from top to bottom in Ant build files. If you define the Enterprise Server Ant tasks at the project level, make sure that any properties used within the task definitions have been resolved before the task definitions. For example, the following snippet defines the sun-appserv-admin task at the project level:
<?xml version="1.0" encoding="UTF-8"?> <project name="glassfish-admin-ant-tasks" default="default"> <property name="asinstalldir" value="c:/glassfishv3/glassfish" /> <taskdef name="sun-appserv-admin" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.AdminTask" classpath="${asintalldir}/modules/sun-appserv-ant.jar" /> ... </project>