JBoss.org Community Documentation

Chapter 31. Configuring Stateful Session Beans with deployment descriptors in EJB3

Take a look at the META-INF/ejb-jar.xml and org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCartBean. You specify a stateful bean with the "session" and "session-type" tags. Note that all bean types in EJB 3.0 are homeless, so there is no requirement for a "home" or "local-home" tag. The bean class is specified with the "ejb-class" tag.

ShoppingCartBean also implements a business-remote interface. Take a look at org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCart. To define this as the business-remote interface of ShoppingCartBean you need to use the "business-remote" tag in the ejb-jar.xml. Here's the META-INF/ejb-jar.xml:

			
<session>
         <ejb-name>ShoppingCart</ejb-name>
         <business-remote>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCart</business-remote>
         <ejb-class>org.jboss.tutorial.stateful_deployment_descriptor.bean.ShoppingCartBean</ejb-class>
         <session-type>Stateful</session-type>
         <remove-method>
            <bean-method>
               <method-name>checkout</method-name>
            </bean-method>
            <retain-if-exception>false</retain-if-exception>
         </remove-method>
         <transaction-type>Container</transaction-type>
</session>			
			
		

Note

There's a very important difference between the remote and a business-remote interface. The EJB2.x remote interfaces, which extend from EJBObject, are referred through the <remote> tag in the ejb-jar.xml. On the other hand, the EJB3 style Plain Old Java Interface which is implemented by your EJB3 style POJO bean is known as the business-remote interface and is represented by the @Remote and it's corresponding <business-remote> tag in ejb-jar.xml. Similar is the case with <local> and the <business-local> tags in ejb-jar.xml.

@Remove :

Take another look at META-INF/ejb-jar.xml. Look for the "remove-method" tag. Instead of explicitly calling EJBObject.remove() in your applications and thus polluting it further with J2EE specific code, any method specified in the "remove-method" tag will cause the stateful bean instance to be removed from the container at the end of the method call. This deployment descriptor behavior mimics the @Remove annotation.

JNDI Bindings through deployment descriptor :

The CalculatorBean will have its remote interface bound in JNDI. Take a look at META-INF/jboss.xml. Note the jndi-name tag. This specifies the jndi binding for the remote interface of the bean.