Home arrow Java & J2EE arrow Page 11 - Introduction to Enterprise JavaBeans

Examining the Case Study Application - Java

This chapter looks at one of the principal types of component in the Java 2 Platform, Enterprise Edition (J2EE) — Enterprise JavaBeans (EJBs). See how EJBs are applied and how they are deployed. (This is chapter 4 from Sams Publishers, author Martin Bond, et. al., Teach Yourself J2EE in 21 Days, second edition, ISBN: 0-672-32558-6).

TABLE OF CONTENTS:
  1. Introduction to Enterprise JavaBeans
  2. Types of EJB and Common Uses of EJBs
  3. What's in an EJB?
  4. The Home Interface
  5. Implementing the Home Interface
  6. Verifying an EJB
  7. The EJB-JAR File
  8. How Do I Deploy an EJB?
  9. Disposing of the EJB
  10. Using the J2EE Reference Implementation
  11. Examining the Case Study Application
  12. Verifying the Case Study Application
  13. Managing J2EE RI Applications
  14. Troubleshooting the Case Study Application
By: Martin Bond
Rating: starstarstarstarstar / 41
June 21, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

You can use deploytool to examine and alter deployment descriptor information for the application and, if necessary, for individual components, such as EJBs.

After you open an EAR file, the enterprise application will be selected and deployment information appropriate to the application is available in the tabbed dialog pages in the right pane. In Figure 4.3, clicking on the key icons to the left of each item has exposed the nested structure of the information.

bond

Figure 4.3
The Agency application loaded by deploytool.

Figure 4.3 shows that the application has three components:

  • An Agency JAR file containing a single Agency EJB

  • A WebApp WAR file containing a simple Web Application (Web Applications are introduced on Day 12)

  • A SimpleClient client application

The right General pane in Figure 4.3 shows the files comprising the Agency application as follows:

  • META-INF/application.xml—The application DD as shown in Listing 4.6

  • META-INF/sun-j2ee-ri.project—A proprietary J2EE RI projects file (you can ignore this)

  • META-INF/sun-j2ee-ri.xml—A J2EE RI platform-specific DD (discussed in the section "Defining the Platform-Specific Settings")

  • agency-session-ejb.jar—The JAR file for the Agency EJBs

  • app-client-ic.jar—The JAR file for the application client

  • webagency.war—The WAR file for the Web Application

The remaining tabbed dialog-pages in the application pane will be discussed in later days in this book.

With the agency application selected in the left pane you can use the Tools, Descriptor Viewer, Descriptor Viewer menu option to examine the application.xml deployment descriptor shown in Listing 4.6. You can also use the Tools, Descriptor Viewer, Application Server Descriptor... menu to view the Sun Specific deployment descriptor.

Figure 4.4 shows the EJB JAR specific information with the contents of the JAR file expanded in the right pane.

bomd

Figure 4.4
Details of the Agency JAR file.

The right General pane in Figure 4.4 shows the files that compose the Agency EJB JAR:

  • META-INF/ejb-jar.xml—The EJB DD

  • META-INF/sun-ejb-jar.xml—The Sun Specific EJB DD

  • META-INF/sun-j2ee-ri.project—A proprietary J2EE RI projects file (you can ignore this)

  • agency/Agency.class—The Agency Session bean remote interface (see Listing 4.1)

  • agency/AgencyBean.class—The Agency Session bean itself (see Listing 4.3)

  • agency/AgencyHome.class—The Agency Session bean home interface (see Listing 4.2)

  • agency/DuplicateException.class—Supporting class for the Agency Session

  • agency/NotFoundException.class—Supporting class for the Agency Session

With the Agency EJB JAR file selected in the left pane you can use the Tools, Descriptor Viewer, Descriptor Viewer menu option to examine the ejb-jar.xml deployment descriptor shown in Listing 4.5. You can also use the Tools, Descriptor Viewer, Application Server Descriptor... menu to view the Sun Specific EJB deployment descriptor.

Drilling down further into the EJB, Figure 4.5 shows the Agency Session bean itself.

bond

Figure 4.5
Details of the Agency Session bean.

In Figure 4.5 the General tab shows the bean type and component classes for the Agency Session bean. This information is provided when the bean is created and cannot be changed thereafter. Creating a Session bean is discussed on Day 5. However, most of the configuration information for a bean can be changed through the remaining tabbed dialog pages shown in Figure 4.5.

Table 4.1 shows the basic categories of information that can be provided for an EJB.

Table 4.1 EJB DD Categories.

Category

Description

Environment Entries

Name value pairs that can be used by the developer but defined by the Deployer/Assembler (see Figure 4.6).

EJB References

References to other EJBs used by this EJB, typically Entity beans referenced by a Session bean, as shown on Day 6.

Resource Environment References

Resource references added to the EJB environment, typically JMS resources, as discussed on Day 10.

Resource References

Resources used by the EJB, such as database connections (see Figure 4.7), JavaMail objects and JMS resources.

Security

Security configuration, as discussed on Day 15, "Security."

Transactions

Transaction requirements, as discussed in detail on Day 8.

Message Destination References

Message-Driven Bean destinations, as discussed on Day 10.

Web Service Endpoints

Web Service endpoints, as discussed on Day 20, "Using RPC-Style Web Services with J2EE," and Day 21, "Message-Style Web Services and Web Service Registries."

Web Service References

References to Web Services, as discussed on Day 21.


The Agency EJB illustrates common requirements for most EJBs. The use of environment references is shown in Figure 4.6, where the displayable Agency name is stored as a String environment reference. The data source definition for the Agency database is shown in Figure 4.7.

bond

Figure 4.6
Agency name stored as an environment entry.

bond

Figure 4.7
Agency database Resource Reference.

Finally, you can examine the simple application client in the Agency EAR file. In Figure 4.8, the main dialog page for an application client has been selected to show the entry for the Main Class name.

bond

Figure 4.8
Simple Client for the Agency application.

In Figure 4.8, you can see that an application client has similar configuration requirements as an EJB. Most of the tabbed dialog pages available are the same as those for an EJB. Figure 4.9 shows the configuration of the Agency Session EJB reference defined for the simple client.

bond

Figure 4.9
Agency Session EJB Reference.

This chapter is from Teach Yourself J2EE in 21 Days, second edition, by Martin Bond et. al. (Sams, 2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy this book now.



 
 
>>> More Java & J2EE Articles          >>> More By Martin Bond
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: