Exit Print View

Sun GlassFish Enterprise Server v3 Application Development Guide

  This Document Entire Library
Print View

Document Information

Preface

Part I Development Tasks and Tools

1.  Setting Up a Development Environment

2.  Class Loaders

3.  Using Ant with Enterprise Server

Setting Up Your Ant Environment

Defining the ANT_OPTS Variable

Defining a Target

Enterprise Server Ant Tasks

The sun-appserv-deploy Task

Subelements of sun-appserv-deploy

Attributes of sun-appserv-deploy

Examples of sun-appserv-deploy

The sun-appserv-undeploy Task

Subelements of sun-appserv-undeploy

Attributes of sun-appserv-undeploy

Examples of sun-appserv-undeploy

The sun-appserv-instance Task

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

The sun-appserv-admin Task

Subelements of sun-appserv-admin

Attributes of sun-appserv-admin

Examples of sun-appserv-admin

The sun-appserv-jspc Task

Attributes of sun-appserv-jspc

Example of sun-appserv-jspc

The sun-appserv-update Task

Attributes of sun-appserv-update

Example of sun-appserv-update

The wsgen Task

Attributes of wsgen

Example of wsgen

The wsimport Task

Attributes of wsimport

Example of wsimport

Reusable Subelements

The server Subelement

Attributes of server

Examples of server

The component Subelement

Attributes of component

Examples of component

The fileset Subelement

4.  Debugging Applications

Part II Developing Applications and Application Components

5.  Securing Applications

6.  Developing Web Services

7.  Using the Java Persistence API

8.  Developing Web Applications

9.  Using Enterprise JavaBeans Technology

10.  Using Container-Managed Persistence

11.  Developing Java Clients

12.  Developing Connectors

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

17.  Using the Java Message Service

18.  Using the JavaMail API

Index

Setting Up Your Ant Environment

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.

Defining the ANT_OPTS Variable

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

Defining a Target

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>