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

Reusable Subelements

Reusable subelements of the Ant tasks for the Enterprise Server are as follows. These are objects upon which the Ant tasks act.

The server Subelement

Specifies an Enterprise Server instance. Allows a single task to act on multiple server instances. The server attributes override corresponding attributes in the parent task; therefore, the parent task attributes function as default values.

Attributes of server

The following table describes attributes for the server element.

The server Attributes
Attribute
Default
Description
user
admin
(optional) The user name used when logging into the Enterprise Server domain administration server (DAS).
passwordfile
none
(optional) File containing passwords. The password from this file is retrieved for communication with the Enterprise Server DAS.
host
localhost
(optional) Target server. When targeting a remote server, use the fully qualified host name.
port
4848
(optional) The administration port on the target server.
instance
name of default instance
(optional) Target application server instance.
instanceport
none
(applies to The sun-appserv-instance Task only) Deprecated.
debug
false
(applies to The sun-appserv-instance Task only, optional) Deprecated. If action is set to start, specifies whether the server starts in debug mode. This attribute is ignored for other values of action. If true, the instance generates additional debugging output throughout its lifetime.
upload
true
(applies to The sun-appserv-deploy Task only, optional) If true, the component is transferred to the server for deployment. If the component is being deployed on the local machine, set upload to false to reduce deployment time.
virtualservers
default virtual server only
(applies to The sun-appserv-deploy Task only, optional) A comma-separated list of virtual servers to be deployment targets. This attribute applies only to application (.ear) or web (.war) components and is ignored for other component types.
Examples of server

You can control multiple servers using a single task. In this example, two servers are started, each using a different password. Only the second server is started in debug mode.

<sun-appserv-instance action="start">
<server host="greg.sun.com" passwordfile="${password.greg}"/>
<server host="joe.sun.com" passwordfile="${password.joe}"
     debug="true"/>
</sun-appserv-instance>

You can create instances on multiple servers using a single task. This example creates a new instance named qa on two different servers. Both servers use the same password.

<sun-appserv-instance action="create" instanceport="8080"
     instance="qa" passwordfile="${passwordfile}>
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
</sun-appserv-instance>

These instances can also be removed from their respective servers:

<sun-appserv-instance action="delete" instance="qa"
     passwordfile="${passwordfile}>
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
</sun-appserv-instance>

You can specify different instance names and instance ports using attributes of the nested server element:

<sun-appserv-instance action="create" passwordfile="${passwordfile}>
<server host="greg.sun.com" instanceport="8080" instance="qa"/>
<server host="joe.sun.com" instanceport="9090"
    instance="integration-test"/>
</sun-appserv-instance>

You can deploy multiple components to multiple servers (see the The component Subelement) . This example deploys each component to two Enterprise Server instances running on remote servers. Both servers use the same password.

<sun-appserv-deploy passwordfile="${passwordfile}" 
  asinstalldir="/opt/s1as8" >
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"
     contextroot="test"/>
<component file="${assemble}/simplebean.jar"/>
</sun-appserv-deploy>

You can also undeploy multiple components from multiple servers. This example shows the same three components being removed from two different instances. Both servers use the same password.

<sun-appserv-undeploy passwordfile="${passwordfile}">
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-undeploy>

You can enable or disable components on multiple servers. This example shows the same three components being enabled on two different instances. Both servers use the same password.

<sun-appserv-component action="enable" passwordfile="${passwordfile}">
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-component>

The component Subelement

Specifies a Java EE component. Allows a single task to act on multiple components. The component attributes override corresponding attributes in the parent task; therefore, the parent task attributes function as default values.

Attributes of component

The following table describes attributes for the component element.

The component Attributes
Attribute
Default
Description
file
none
(optional if the parent task is The sun-appserv-undeploy Task or The sun-appserv-component Task) The target component. If this attribute refers to a file, it must be a valid archive. If this attribute refers to a directory, it must contain a valid archive in which all components have been exploded. If upload is set to false, this must be an absolute path on the server machine.
name
file name without extension
(optional) The display name for the component.
force
true
(applies to The sun-appserv-deploy Task only, optional) If true, the component is overwritten if it already exists on the server. If false, the containing element’s operation fails if the component exists.
precompilejsp
false
(applies to The sun-appserv-deploy Task only, optional) If true, all JSP files found in an enterprise application (.ear) or web application (.war) are precompiled. This attribute is ignored for other component types.
retrievestubs
client stubs not saved
(applies to The sun-appserv-deploy Task only, optional) The directory where client stubs are saved.
contextroot
file name without extension
(applies to The sun-appserv-deploy Task only, optional) The context root for a web module (WAR file). This attribute is ignored if the component is not a WAR file.
verify
false
(applies to The sun-appserv-deploy Task only, optional) If true, syntax and semantics for all deployment descriptors is automatically verified for correctness.
Examples of component

You can deploy multiple components using a single task. This example deploys each component to the same Enterprise Server instance running on a remote server.

<sun-appserv-deploy passwordfile="${passwordfile}" host="greg.sun.com"
     asinstalldir="/opt/s1as8" >
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"
     contextroot="test"/>
<component file="${assemble}/simplebean.jar"/>
</sun-appserv-deploy>

You can also undeploy multiple components using a single task. This example demonstrates using the archive files (EAR and WAR, in this case) and the component name (for the EJB component).

<sun-appserv-undeploy passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-undeploy>

You can deploy multiple components to multiple servers. This example deploys each component to two instances running on remote servers. Both servers use the same password.

<sun-appserv-deploy passwordfile="${passwordfile}" asinstalldir="/opt/s1as8" >
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"
    contextroot="test"/>
<component file="${assemble}/simplebean.jar"/>
</sun-appserv-deploy>

You can also undeploy multiple components to multiple servers. This example shows the same three components being removed from two different instances. Both servers use the same password.

<sun-appserv-undeploy passwordfile="${passwordfile}">
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-undeploy>

You can enable or disable multiple components. This example demonstrates disabling multiple components using the archive files (EAR and WAR, in this case) and the component name (for the EJB component).

<sun-appserv-component action="disable" passwordfile="${passwordfile}">
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-component>

You can enable or disable multiple components on multiple servers. This example shows the same three components being enabled on two different instances. Both servers use the same password.

<sun-appserv-component action="enable" passwordfile="${passwordfile}">
<server host="greg.sun.com"/>
<server host="joe.sun.com"/>
<component file="${assemble}/simpleapp.ear"/>
<component file="${assemble}/simpleservlet.war"/>
<component name="simplebean" />
</sun-appserv-component>

The fileset Subelement

Selects component files that match specified parameters. When fileset is included as a subelement, the name and contextroot attributes of the containing element must use their default values for each file in the fileset. For more information, see http://ant.apache.org/manual/CoreTypes/fileset.html.