2.2.2. Deployment Descriptors
Each component module (except for applet jar files) includes a standard J2EE deployment
descriptor. These descriptors are key to the assembly and deployment process in J2EE.
The deployment descriptor knits together all the bits and pieces in the module jar file into
actual components and describes to the container how each component should be
managed. Without the deployment descriptor, the module jar just looks like a bag of Java
classes and other files to the container.
Component deployment descriptors specify these major sets of information for the
Module descriptive information
In most cases, a component module as a whole can be given some descriptive
information, such as a name, a description, and so on. This information can be used
by application server management tools and server logs to provide human-readable
information about the components deployed in the server.
Each component (EJB, web, or resource connector) is made up of one or more parts.
A web component is implemented as either a servlet class or a JSP file. An entity EJB
is implemented as a bean implementation class, one or more client interfaces, one or
more home interfaces, and a primary key class. For each component in the module
jar file, the container needs to be told the parts that make up the component.
Configuration data for component services
Each type of component makes use of specific services provided by the container.
Some of these services are optional; some are part of the standard runtime
management provided by the container. Web components use basic instantiation and
lifecycle services, optional security services, and so on. EJBs use more elaborate
lifecycle services, security services, persistence services, transaction management
services, and so on. Where there are options in terms of how these services are
managed at runtime, the deployment descriptor allows you to specify these options.
Resource and component dependencies
A component may make use of various resources that are expected to be deployed in
its runtime environment in the application server. These may include JDBC
DataSources used to make database connections, JavaMail Sessions used to create
and send/receive email messages, and so on. Also, components can make use of other
components. A web component might make use of a session EJB to perform some key
tasks on behalf of users of its interface, and the session EJB may in turn make use of
an entity EJB to access persistent data. These dependencies on external resources and
components need to be declared in the deployment descriptor as well.
The full format of each of the various component deployment descriptors is described in
Appendix A and the details of their use are demonstrated in the examples in Chapters 3,
4, 6, and 12. The following example demonstrates the general assembly process for
component modules , including the use of deployment descriptors.[*]