EJB – Annotations

  • Post author:
  • Post category:EJB
  • Post comments:2 Comments
EJB - Annotations

In this guide we will discuss about Annotations of EJB. Annotations were introduced in Java 5.0. The purpose of having annotations is to attach additional information in the class or a meta-data of a class within its source code. In EJB 3.0, annotations are used to describe configuration meta-data in EJB classes. By this way, EJB 3.0 eliminates the need to describe configuration data in configuration XML files.

EJB container uses compiler tool to generate required artifacts like interfaces, deployment descriptors by reading those annotations. Following is the list of commonly used annotations.

Sr.noNameDescription
1javax.ejb.StatelessSpecifies that a given EJB class is a stateless session bean.Attributesname โˆ’ Used to specify name of the session bean.mappedName โˆ’ Used to specify the JNDI name of the session bean.description โˆ’ Used to provide description of the session bean.
2javax.ejb.StatefulSpecifies that a given EJB class is a stateful session bean.Attributesname โˆ’ Used to specify name of the session bean.mappedName โˆ’ Used to specify the JNDI name of the session bean.description โˆ’ Used to provide description of the session bean.
3javax.ejb.MessageDrivenBeanSpecifies that a given EJB class is a message driven bean.Attributesname โˆ’ Used to specify name of the message driven bean.messageListenerInterface โˆ’ Used to specify message listener interface for the message driven bean.activationConfig โˆ’ Used to specify the configuration details of the message-driven bean in an operational environment of the message driven bean.mappedName โˆ’ Used to specify the JNDI name of the session bean.description โˆ’ Used to provide description of the session bean.
4javax.ejb.EJBUsed to specify or inject a dependency as EJB instance into another EJB.Attributesname โˆ’ Used to specify name, which will be used to locate the referenced bean in the environment.beanInterface โˆ’ Used to specify the interface type of the referenced bean.beanName โˆ’ Used to provide name of the referenced bean.mappedName โˆ’ Used to specify the JNDI name of the referenced bean.description โˆ’ Used to provide description of the referenced bean.
5javax.ejb.LocalUsed to specify Local interface(s) of a session bean. This local interface states the business methods of the session bean (which can be stateless or stateful).This interface is used to expose the business methods to local clients, which are running in the same deployment/application as EJB.Attributesvalue โˆ’ Used to specify the list of local interfaces as an array of interfaces.
6javax.ejb.RemoteUsed to specify Remote interface(s) of a session bean. This remote interface states the business methods of the session bean (which can be stateless or stateful).This interface is used to expose the business methods to remote clients, which are running in different deployment/application as EJB.Attributesvalue โˆ’ Used to specify the list of remote interfaces as an array of interfaces.
7javax.ejb.Activation ConfigPropertyUsed to specify properties required for a message driven bean. For example, end point, destination, message selector etc.This annotation is passed as a parameter to activationConfig attribute of javax.ejb.MessageDrivenBean annotation.AttributespropertyName โˆ’ name of the property.propertyValue โˆ’ value of the property.
8javax.ejb.PostActivateUsed to specify callback method of EJB lifecycle. This method will be called when EJB container just activated/reactivated the bean instance.This interface is used to expose the business methods to local clients, which are running in same deployment/application as EJB.

Next Topic : Click Here

This Post Has 2 Comments

  1. โ€ipod nano

    Very good article.Really looking forward to read more. Really Cool.

Leave a Reply