EJB 3.1 annotations and their deployment descriptor equivalents

The following table illustrates the translation between EJB 3.1 annotations and XML data in the deployment descriptor.
Table 1. Annotations and their deployment descriptor equivalents
Annotation Attributes Description Corresponding deployment descriptor element
EJB Annotations (JSR-220)      
@Stateless
java.lang.String     description

 java.lang.String     mappedName

 java.lang.String     name 
Component-defining annotation for a stateless session bean. The isIdentical method always returns true when used to compare object references of two session objects of the same stateless session bean (that is, they are functionally interchangeable).
<session>--<ejb-name>
<session>--<mapped-name>
<session>--<ejb-class>
<session>--<session-type>

if annotated type implements some interface:

<session>--<local>

<session>--<local-home>
@Stateful
java.lang.String     description

 java.lang.String     mappedName

 java.lang.String     name 
Component-defining annotation for a stateful session bean.
<session>--<ejb-name>
<session>--<mapped-name>
<session>--<ejb-class>
<session>--<session-type>
@Local
java.lang.Class[]     value
When used on the bean class, declares the local business interfaces for a session bean. When used on an interface, designates that interface as a local business interface. In this case, no value() is provided.
<session>--<local>
@LocalHome
java.lang.Class     value
Declares the Local Home or adapted Local Home interface for a session bean.
<session>--<local home>
@Remote
java.lang.Class[]     value
Declares the remote business interfaces for a session bean. When used on an interface, designates that interface as a remote business interface. In this case, no value() is provided.
<session>--<remote>
@RemoteHome
java.lang.Class     value
Declares the Remote Home or adapted Remote Home interface for a session bean.
<session>--<remote home>
@Remove
boolean     retainIfException
Applied to a business method of a stateful session bean class. Indicates that the stateful session bean is to be removed by the container after completion of the method
<remove-method>--<bean-method>

<remove-method>--<retain-if-exception>
@Init
java.lang.String     value  
(The name of the corresponding create method of the adapted Home/LocalHome interface)
Designates a method of a session bean that corresponds to the create method of an adapted Home interface or an adapted Local Home interface.
<init-method>--<create-method>

<init-method>--<bean-method> 
@Timeout NONE Designates a method on a stateless session bean class or message driven bean class that should receive EJB timer expirations for that bean.
<timeout-method>
@MessageDriven
ActivationConfigProperty[]     activationConfig

java.lang.String     description

java.lang.String     mappedName

java.lang.Class     messageListenerInterface

java.lang.String     name 
Component-defining annotation for a message driven bean.
<message-driven>--<ejb-name>
<message-driven>--<mapped-name>
<message-driven>--<ejb-class>
<message-driven>--<messaging-type> <message-driven>--<activation-config-property>
@TransactionAttribute
TransactionAttributeType     value
When applied at the TYPE-level, designates the default transaction attribute for all business methods of the session or message driven bean. When applied at the method-level, designates the transaction attribute for only that method.
<container-transaction>
@TransactionManagement
TransactionManagementType  value
Declares whether a session bean or message driven bean has container managed transactions or bean managed transactions.
<transaction-type>
@PostActivate NONE Designates a method to receive a callback after a stateful session bean has been activated.
<post-activate>
@PrePassive NONE Designates a method to receive a callback before a stateful session bean is made passive.
<pre-activate>
@EJB
java.lang.Class     beanInterface
(Holds one of the following interface types of the target EJB : [ Local business interface, Remote business interface, Local Home interface, Remote Home interface ])
 java.lang.String     beanName

 java.lang.String     mappedName

 java.lang.String     name  
Indicates a dependency on the local or remote view of an Enterprise Java™ Bean.
<ejb-ref>--<ejb-ref-name>
<ejb-ref>--<home>     
<ejb-ref>--<remote>

<ejb-local-ref>--<ejb-ref-name>
<ejb-local-ref>--<local-home>     
<ejb-local-ref>--<local>
@EJBs   Declares multiple TYPE-level @EJB annotations.  
@ApplicationException
EJB[]     value
Applied to an exception to denote that it is an application exception and should be reported to the client directly (that is, unwrapped).
<application-exception>--<exception-class>

<application-exception>--<rollback>
@ActivationConfigProperty
java.lang.String     propertyName

 java.lang.String     propertyValue boolean     rollback
Represents activation config property
<activation-config-property>

           --<activation-config-property-name>

<activation-config-property>

           --<activation-config-property-value>
@AroundInvoke NONE Specifies a method on a class to be called during the around invoke portion of an ejb invocation
<around-invoke>--<class>
<around-invoke>--<method-name>
@ExcludeClassInterceptors NONE Used to exclude class-level interceptors for a business method.
<exclude-class-interceptors>
@ExcludeDefaultInterceptors NONE Used to exclude default interceptors for a bean or a business method.
<exclude-default-interceptors>
@Interceptors
java.lang.Class[]     value
Declares an ordered list of interceptors for a class or method.
<interceptors>--<interceptor>
Common Annotations (JSR 250)      
@Generated
java.lang.String[]     value   

 java.lang.String  comments

 java.lang.String     date 
The @Generated annotation is used to mark source code that has been generated. It can also be used to differentiate user written code from generated code in a single file. When used, the value element must have the name of the code generator. The recommended convention is to use the fully qualified name of the code generator in the value field. For example: com.company.package.classname. The date element is used to indicate the date the source was generated. The date element must follow the ISO 8601 standard. For example the date element would have the following value 2011-07-04T12:08:56.235-0700 which represents 2011-07-04 12:08:56 local time in the U.S. Pacific time zone. The comment element is a place holder for any comments that the code generator may want to include in the generated code. The only annotation with SOURCE retention. All the others are RUNTIME. NONE
@PostConstruct NONE The @PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.
<post-construct>--<lifecycle-callback-class>
<post-construct>--<lifecycle-callback-method>
@PreDestroy NONE The @PreDestroy annotation is used on methods as a callback notification to signal that the instance is in the process of being removed by the container.
<pre-destroy>--<lifecycle-callback-class>
<pre-destroy>--<lifecycle-callback-method>
@Resource
Resource.AuthenticationType     authenticationType
   
The authentication type to use for this resource.
java.lang.String  description

 java.lang.String mappedName

 java.lang.String     name
The JNDI name of the resource.
boolean     shareable
Indicates whether this resource can be shared between this component and other components.
Class     type
The Java type of the resource.
The @Resource annotation marks a resource that is needed by the application. This annotation may be applied to an application component class, or to fields or methods of the component class. When the annotation is applied to a field or method, the container injects an instance of the requested resource into the application component when the component is initialized. If the annotation is applied to the component class, the annotation declares a resource that the application looks up at runtime.
env-entry
        <env-entry-name>
        <env-entry-value>  
        <env-entry-type>

service-ref
resource-ref
message-destination-ref
resource-env-ref
@Resources      
@DeclareRoles
String[] value
Used by application to declare roles.
<security-role>--<role-name>
@DenyAll NONE Specifies that no security roles are allowed to invoke the specified methods - that is, that the methods are to be excluded from execution in the J2EE container.
<exclude-list>--<method>
@PermitAll NONE Specifies that all security roles are allowed to invoke the specified methods - that is, that the specified methods are cleared. It can be specified on a class or on methods. Specifying it on the class means that it applies to all methods of the class. If specified at the method level, it only affects that method. If the RolesAllowed is specified at the class level and this annotation is applied at the method level, the PermitAll annotation overrides the RolesAllowed for the specified method.
<method-permission>--<method>
@RolesAllowed
String[] value
Specifies the list of roles permitted to access methods in an application. The value of the RolesAllowed annotation is a list of security role names. This annotation can be specified on a class or on methods.
<method-permission>--<role-name>
<method-permission>--<method>
@RunAs
String value
Defines the identity of the application during execution in a J2EE container. This allows developers to execute under a particular role. The role must map to the user / group information in the containers security realm. Its value is the name of a security role.
<security-identity>--<run-as>

Feedback