Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Session Bean Configuration and Deployment

In the last article, I introduced the basic top-level structure of an EJB application module deployment descriptor. The root <ejb-jar> element contained an <enterprise-beans> element, which could contain a collection of <session> elements. Each <session> element is used to describe the configuration and deployment of an individual session bean.

The <session> bean element, shown in Listing 2, defines session bean metadata, a unique name in the EJB JAR file, the bean's class and interface names, the type of session bean, configuration parameters, references to other EJBs and database connections, security semantics, and a transaction flag. The session-related elements of an example stateful session bean's ejb-jar.xml file are shown in Listing 2. You'll note that in addition to standard metadata and structural information about the EJB, it has defined <ejb-ref> elements for all the EJBs that it accesses as a client to those beans.

Listing 2 Example of EJB Session Bean Deployment Descriptor Information

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//
[ic:ccc]DTD Enterprise JavaBeans 1.1//EN'
[ic:ccc] 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

<ejb-jar>
 <description>A wacky example</description>
 <display-name>CartJar</display-name>
 <enterprise-beans>
  <session>
   <description/>
   <display-name>ShoppingCartSessionEJB</display-name>
   <ejb-name>ShoppingCartSessionEJB</ejb-name>
   <home>ejava.ejbch36.shoppingcart.ShoppingCartSessionHome</home>
   <remote>ejava.ejbch36.shoppingcart.ShoppingCartSession</remote>
   <ejb-class>
    ejava.ejbch36.shoppingcart.ShoppingCartSessionEJBean
   </ejb-class>
   <session-type>Stateful</session-type>
   <transaction-type>Container</transaction-type>
   <ejb-ref>
     <ejb-ref-name>ejb/tshirt</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <home>ejava.ejbch36.tshirt.TShirtHome</home>
     <remote>ejava.ejbch36.tshirt.TShirt</remote>
   </ejb-ref>
   <ejb-ref>
    ...
  </session>
 </enterprise-beans>
  ...
</ejb-jar>

Vendor-specific deployment descriptor files to configure and deploy session beans are also needed. Developers most often use GUI-based deployment tools provided by vendors to develop such files.

  • + Share This
  • 🔖 Save To Your Account