J2EE Applications
You assemble a J2EE application from three kinds of modules: enterprise beans, Web components, and J2EE application clients. These modules are reusable-- you can build new applications from existing enterprise beans and components. And because the modules are portable, the application they comprise will run on any J2EE server that conforms to the specifications.
Contents of a J2EE Application
Figure 1-4 shows the hierarchy of a J2EE application. A J2EE application may contain one or more enterprise beans, Web components, or J2EE application client components. An enterprise bean is composed of three class files-- the EJB class, the remote interface, and the home interface. (The next chapter discusses these class files in more detail.) A Web component may contain files of the following types: servlet class, JSP, HTML, and GIF. A J2EE application client is a Java application that runs in an environment (container) which allows it to access J2EE services.
Each J2EE application, Web component, enterprise bean, and J2EE application client has a deployment descriptor. (Figure 1-4 abbreviates a deployment descriptor as DD.) A deployment descriptor is an .xml file that describes the component. An EJB deployment descriptor, for example, declares transaction attributes and security authorizations for an enterprise bean. Because this information is declarative, it can be changed without requiring modifications to the bean's source code. At run time, the J2EE server reads this information and acts upon the bean accordingly.
FIGURE 1-4 Contents of a J2EE Application
You bundle each module into a file with a particular format-- a J2EE application in a .ear file, an enterprise bean in an EJB .jar file, a Web component in a .war file, and a J2EE application client in a .jar file. An .ear file, for example, contains an .xml file for its deployment descriptor, and one or more EJB .jar and .war files. An EJB .jar contains its deployment descriptor and the .class files for the enterprise bean. The following table lists the file type of every element residing in a J2EE application.
TABLE 1-2 Files Used in a J2EE Application
Element
|
File Type
|
---|
J2EE Application
|
.ear
|
J2EE Application Deployment Descriptor
|
.xml
|
Enterprise Bean
|
ejb .jar
|
EJB Deployment Descriptor
|
.xml
|
EJB Class
|
.class
|
Remote Interface
|
.class
|
Home Interface
|
.class
|
Web Component
|
.war
|
Web Component Deployment Descriptor
|
.xml
|
JSP File
|
.jsp
|
Servlet Class
|
.class
|
GIF File
|
.gif
|
HTML File
|
.html
|
J2EE Application Client
|
.jar
|
J2EE Application Client Deployment Descriptor
|
.xml
|
Java Application
|
.class
|
Development Phases of J2EE Applications
As a J2EE application evolves, it passes through these development phases:
In a large organization, each phase might be executed by different individuals or teams. This division of labor works because each of the earlier phases outputs a portable file that is the input for a subsequent phase. For example, in the Enterprise Bean Creation phase, a software developer delivers EJB .jar files. In the J2EE Application phase, another developer combines these EJB .jar files into a J2EE application and saves it in an .ear file. In the final phase, J2EE Application Deployment, a system administrator at the customer site uses the .ear file to install the J2EE application into a J2EE server. Figure 1-5 illustrates these last two phases.
The different phases are not always executed by different people. If you work for a small company, for example, or if you are protyping a sample application, you might peform the tasks in every phase.
FIGURE 1-5 J2EE Application Assembly and Deployment
The sections that follow summarize the development phases for J2EE applications. Because a J2EE application is not required to have every type of module, only one of the first three phases is required. The final two phases are necessary. Since this manual focuses on enterprise beans, it does not discuss the Web Component Creation phase. The next chapter in this manual, Getting Started, shows you how to build and deploy a sample J2EE application that contains an enterprise bean.
Enterprise Bean Creation
Person: software developer
Tasks:
- Codes and compiles the Java source code needed by the enterprise bean
- Specifies the deployment descriptor for the enterprise bean
- Bundles the .class files and deployment descriptor into an EJB .jar file
Deliverable: the EJB .jar file containing the enterprise bean
Web Component Creation
Persons: Web designer (JavaServer Pages components), software developer (servlets)
Tasks:
- Codes and compiles Java source code for the servlet
- Writes .jsp and .html files
- Specifies the deployment descriptor for the Web component
- Bundles the .class, .jsp, .html, and deployment descriptor files into the .war file
Deliverable: the .war file containing the Web component
J2EE Application Client Creation
Person: software developer
Tasks:
- Codes and compiles the Java source code needed by the client
- Specifies the deployment descriptor for the client
- Bundles the .class files and deployment descriptor into the .jar file for the client.
Deliverable: the .jar file containing the J2EE application client
J2EE Application Assembly
Person: software developer
Tasks:
- Assembles enterprise beans (EJB .jar) and Web components (.war) created in the previous phases into a J2EE application (.ear)
- Specifies the deployment descriptor for the J2EE application
Deliverable: the .ear file containing the J2EE application
J2EE Application Deployment
Person: system administrator
Tasks:
- Adds the J2EE application (.ear) created in the preceding phase to the J2EE server
- Configures the J2EE application for the operational environment by modifying the deployment descriptor of the J2EE application
- Deploys (installs) the J2EE application (.ear) into the J2EE server
Deliverable: an installed and configured J2EE application
Prev | Next
TOC | Index
Copyright © 2000 Sun Microsystems, Inc. All rights reserved.