Describing Enterprise Beans

The enterprise beans contained in a JAR file are laid out within the deployment descriptor’s <enterprise-beans> element. So far, we have talked about deployment descriptors for a single enterprise bean, but it is possible to package several enterprise beans in a JAR file and describe them all within a single deployment descriptor. We could, for example, have deployed the TravelAgent, ProcessPayment, Cruise, Customer, Reservation, and ReservationProcessor EJBs in the same JAR file. The deployment descriptor would look something like this:

<?xml version="1.0" encoding="UTF-8"?>
...
<ejb-jar...>
    <description>
        This Deployment includes all the beans needed to make a reservation:
        TravelAgent, ProcessPayment, Reservation, Customer, Cruise, and Cabin.
    </description>
    <enterprise-beans>
        <session>
            <ejb-name>TravelAgentEJB</ejb-name>
            <remote>com.titan.travelagent.TravelAgentRemote</remote>
            ...
        </session>
        <entity>
            <ejb-name>CustomerEJB</ejb-name>
            <remote>com.titan.customer.CustomerRemote</remote>      
            ...
        </entity>
        <session>
            <ejb-name>ProcessPaymentEJB</ejb-name>
            <remote>com.titan.processpayment.ProcessPaymentRemote</remote>
            ...
        </session>
        <message-driven>
            <ejb-name>ReservationProcessorEJB</ejb-name>
            ...
        </message-driven>
        ...
    </enterprise-beans>
    <relationships>
        ...
    </relationships>
    <assembly-descriptor>
        ...
    </assembly-descriptor>
    ...
</ejb-jar>

In this descriptor, the <enterprise-beans> element contains two <session> elements, one <entity> element, and a <message-driven> ...

Get Enterprise JavaBeans, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.