Annotations, Defaults and XML has been created by David Blevins (Sep 28, 2007).

Content:
Annotation xml element(s) default value
@Stateless
  • <session>
  • <ejb-class>
  • <session-type>Stateless</session-type>
 
  • name
<ejb-name> the simple name of the bean class. For org.acme.superfun.WidgetBean the ejb-name will be WidgetBean
  • description
<description>  
  • mappedName
<mapped-name>  
@Stateful
  • <session>
  • <ejb-class>
  • <session-type>Stateful</session-type>
 
  • name
<ejb-name> the simple name of the bean class. For org.acme.superfun.WidgetBean the ejb-name will be WidgetBean
  • description
<description>  
  • mappedName
<mapped-name>  
@MessageDriven
  • <message-driven>
  • <ejb-class>
  • <session-type>Stateful</session-type>
 
  • name
<ejb-name> the simple name of the bean class. For org.acme.superfun.WidgetBean the ejb-name will be WidgetBean
  • description
<description>  
  • mappedName
<mapped-name>  
  • messageListenerInterface
<messaging-type> the interface the bean class implements. when relying upon the default is illegal for the bean to implement more than one interface

@Stateless or @Stateful on a class replaces the descriptor tags <session>, <ejb-name>, <session-type>Stateless</session-type>, and <session-type>Stateful</session-type>.

@RemoteHome or @LocalHome is used on a class to replace <home> or <local-home>. We inspect the actual home or local-home interface to determine the related <remote> or <local> interface.

@TransactionManagement on a class replaces <transaction-type>

@TransactionAttribute on a class and/or method replaces <container-transaction>. You'll need one @TransactionAttribute for each <container-transaction>/<method> xml element. A <method-name>*</method-name> would turn into an @TransactionAttribute on a class, everything else would go on methods.

@EJB used on a class replaces <ejb-ref> and <ejb-local-ref>. @EJB used on a field or setter method (private or public) request injection of that EJB as well. When @EJB is used on a class the "beanInterface" attribute is required. When used on a field or setter method, the "beanInterface" attribute defaults to the type of the field or setter method.

@Resource used on a class replaces <env-entry>, <resource-ref>, <resource-env-ref>. @Resource used on a field or method (private or public) requests injection of that resource. When @Resource is used on a class, the "type" attribute is required. When used on a field or method, the "type" attribute defaults to the type of the field or setter method.

There are more annotations obviously, but these are fairly simple and get rid of a ton of xml.

Reply via email to