Section 2.3. Application Assemblies

2.3. Application Assemblies

Once we have our components assembled into the appropriate modules, each with a deployment descriptor, we can assemble an application by bundling the component modules along with an application deployment descriptor into an enterprise application archive (ear) file.

Like component modules, an application archive is just a jar file with files stored in specific locations, as dictated by the J2EE specifications. The deployment descriptor is stored as META-INF/application.xml in the jar file, and component modules are placed in the jar and referenced in the application descriptor using their location relative to the top of the application archive. The full syntax of the application deployment descriptors can be found in Appendix A.

Application deployment descriptors are simpler in structure, because they primarily serve to assemble component modules that have their own deployment information. The application deployment descriptor contains the following categories of information:

Application descriptive information

Similar to component modules, applications can also have descriptive information in their deployment descriptors. The application can be given a name and a description that can be displayed in management tools, for example.

Figure 2-5. Web module deployment descriptor

Module references

Each component module to be included in the application must be referenced in its own <module> element in the application.xml file. The module reference indicates the location of the module jar file in the application archive. In the case of web modules, the module can also be given a web context root in the application descriptor. This context root is used as the base of URLs mapped to the components in the module.

Application security roles

Each component module can declare security roles that are used to control access to components and their operations. You can also declare security roles at the application level to indicate application-wide roles that must be mapped to actual users by the application server. Details on the J2EE security model can be found in Chapter 10.

2.3.1. Application Assembly Example

Returning to our example application, we now need to create an application archive containing our application's two component module archives. One module is an EJB module that contains the profile EJB component, and the other is a web module that contains the UI elements, including the JSP used for viewing profiles.

Figure 2-6 shows our application deployment descriptor. The first section of the file contains some descriptive information about the application as a whole. Following this, we declare the two module archives that contain our components. These jar files must be found in the application archive when the application is deployed at the relative locations used here in the <module> elements. Finally, our example descriptor declares some security roles to potentially be used by the application at runtime. As with any roles declared at the component level, the application server should verify that these roles have been configured within its runtime environment when the application is deployed.

Figure 2-6. Application deployment descriptor

Java Enterprise in a Nutshell
Java Enterprise in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596101422
EAN: 2147483647
Year: 2004
Pages: 269
Similar book on Amazon © 2008-2017.
If you may any questions please contact us: