Declaring the Deployment Descriptor

Listing 14.2 shows the ejb-jar.xml deployment descriptor for the OrderVerifier enterprise bean. ejb-jar.xml describes the enterprise bean's deployment properties, such as its bean type and structure. The file also provides the EJB container with information about where it can find and then load the bean class. Message-driven beans don't have home or component interfaces, so you don't specify them in the deployment descriptor. The deployment descriptor may specify the JMS Destination type (Queue or Topic) to which the bean should be assigned.

Listing 14.2. The Full Text of day14/ejb-jar.xml
<!DOCTYPE ejb-jar PUBLIC
 "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
 "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

 <ejb-jar>
   <enterprise-beans>
     <message-driven>
       <ejb-name>OrderVerifierMDB</ejb-name>
       <ejb-class>day14.OrderVerifierMDB</ejb-class>
       <transaction-type>Container</transaction-type>
       <message-driven-destination>
         <destination-type>javax.jms.Topic</destination-type>
         <subscription-durability>NonDurable</subscription-durability>
       </message-driven-destination>
     </message-driven>
   </enterprise-beans>
</ejb-jar>

The ejb-jar.xml declares OrderVerifierMDB as the name of the message-driven bean. The transaction-type element specifies that this bean uses container-managed transactions. Container-managed transactions are discussed in detail on Day 17. The destination-type element within the message-driven-destination element specifies that the bean consumes topic messages. The subscription-durability element specifies that the message-driven bean's subscription to the Topic is NonDurable. This means the messages may be missed when the EJB server goes down for any period of time.

Listing 14.3 shows the weblogic-ejb-jar.xml deployment descriptor that is specific to WebLogic Server. The destination-jndi-name element specifies that OrderVerifierMDB subscribes to the OrderVerifierTopic Topic.

Listing 14.3. The Full Text of day14/weblogic-ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN'
'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
   <weblogic-enterprise-bean>
    <ejb-name>OrderVerifierMDB</ejb-name>
    <message-driven-descriptor>
      <pool>
        <max-beans-in-free-pool>20</max-beans-in-free-pool>
        <initial-beans-in-free-pool>5</initial-beans-in-free-pool>
      </pool>
    <destination-jndi-name>OrderVerifierTopic</destination-jndi-name>
    </message-driven-descriptor>
  <jndi-name>day14/OrderVerifier</jndi-name>
  </weblogic-enterprise-bean>
</weblogic-ejb-jar>

Listing 14.4 shows the jboss.xml deployment descriptor specific to the JBoss server. The destination-jndi-name element specifies that OrderVerifierMDB subscribes to the topic/OrderVerifierTopic Topic.

Listing 14.4. The Full Text of day14/jboss.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss>
  <enterprise-beans>
    <message-driven>
     <ejb-name>OrderVerifierMDB</ejb-name>
<destination-jndi-name>topic/OrderVerifierTopic</destination-jndi-name>
    </message-driven>
  </enterprise-beans>
</jboss>
					

Later today, you'll learn how to configure a topic in both WebLogic Server and JBoss.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.84