New Features of EJB3

The purpose of EJB 3.0 is to improve the EJB architecture by reducing its complexity from the EJB developer's point of view

The following annottaions are used in the EJB 3.0 applications :
Annotations (Meatadata) Usages Bean Type
@Stateless It is designed for Stateless Session Bean and provides all the features of Stateless Session Bean Stateless
@Statefull It is designed for Stateful Session Bean and provides all the features of Stateful Session Bean Stateful
@Remote This annotation enables EJB component to access from remote-client. It is also used to access from local client Stateless,Stateful
@RemoteHome It is used for Remote Home interface or adapted Remote Home interface for a Session bean. Stateless,Stateful
@Local This annotation enables EJB component to access from local client only. It can not access from remote client Stateless,Stateful
@LocalHome This annotation is used for Local Home or adapted Local Home interface for a Session bean. Stateless,Stateful
@PostConstruct The PostConstruct annotated method is executed after dependency injection is done if any to perform any initialization Stateless,Stateful
@PreDestroy The PreDestroy annotated method is executed when bean instance is in the process of being removed by the container Stateless,Stateful
@PostActivate The @PostActivate annotated method called by the container after a Stateful Session Bean has been activated Stateful
@PrePassivate The @PrePassivate annotated method called by the container before a Stateful Session Bean is passivated Stateful
@Init It is designed to implement the create() method of previous version of EJB in EJB3 Stateless,Stateful
@Remove This annotation is used to end the life of Stateful Session Bean. This annotated method called by the client afterthat container clear up resources ASAP else wait for Session time out Stateful
@EJB This annotation is used to locate the Enterprise Java Bean as dependency injection of Session beans in the J2EE components (JSP,Servlet and EJB). It can be used for local and remote interface in J2EE container. It does not work prefectly with Stateful Session Bean. Stateless,Stateful
@EJBs It is used to multiple type of @EJB Stateless,Stateful
@Interceptor The @Interceptor annotation is used with @Interceptors to define target class Stateless,Stateful
@Interceptors The @Interceptors annotation is used an ordered list of interceptors for a class or method Stateless,Stateful
@ExecludeDefaultInterceptor   Stateless,Stateful
@AroundInvoke The @AroundInvoke annotation is used to defines an interceptor method that interposes on business methods Stateless,Stateful
@Resource Dependency Injection of resources such as Data-Source, JMS objects, etc  
@Timeout It is used to execute a method after timer expirations. Stateless, MDB
@MessageDriven The @MessageDriven annotation is used to provide messaging that JMS destination the MDB wants to receive messages from MDB
@ActivationConfigProperty   MDB
@TransactionManagement It is used to specify whether Session or Message Driven Bean use Bean Managed Transaction or Container Managed Transaction Session, MDB
@TrasactionAttribute It is used to specify the strategy for Transaction type in the container. Session, MDB
@WebService This annotation is used to create WebServices in EJB project Stateless
@WebParam It is used to specify the parameter to the WebServices method Stateless
@WebMethod It is used for alias name of WebServices Stateless
@PersistenceContext To ontained the object of EntityManager for database tasks JPA
@PrePersist It is life cycle callback method for Entity Instance JPA
@PostPersist It is life cycle callback method for Entity Instance JPA
@PreUpdate It is life cycle callback method for Entity Instance JPA
@PostUpdate It is life cycle callback method for Entity Instance JPA
@PreRemove It is life cycle callback method for Entity Instance JPA
@PostRemove It is life cycle callback method for Entity Instance JPA
@PostLoad It is life cycle callback method for Entity Instance JPA
JPA Annotations
@Entity To Specify Entity class JPA
@Table To specify table name other than Entity class name JPA
@Id To represent primary column. JPA
@GeneratedValue To generate value for primary key JPA
@Column To specify column name other than class property JPA
@OneToOne To describe one to one relationship between two Entities JPA
@OneToMany To describe one to many relationship between two Entities JPA
@ManyToOne To describe many to one relationship between two Entities JPA
@Descriminator It is used in Inheritence relationship JPA
@Inheritence It is used in Inheritence relationship JPA
@Version Specifies the version field or property of an entity class that serves as its optimistic lock value. JPA
@JoinColumn Specifies a column for joining an entity association or element collection. JPA
  • XML (Depolyment Descriptor)and Metadata Annotations :
    • A deployment descriptor is a simple XML file that contains application configuration information. It is optional in EJB3.
    • It is annotate EJB applications.
    • These metadata annotations are targeted at simplifying the developers task reduce the source code
  • Dependency Injection :
    • Dependency Injection (DI) in OOP is a design pattern with a core principle of separating behavior from dependency resolution.A technique for decoupling highly dependent software components
    • Any component can use another components or a resources to implement functionality, the main objective of Dependency Injection (DI) is make it as loosely coupled as possible with other components, which means that one component should call another component or resource only through an interface.
  • Interceptors : Inject before and after the EJB method execution
  • Lifecycle callback methods : Container calls these methods to manage component
  • POJO Implementation : EJB 3 works on POJO class.
  • JPA : Simplification of entity persistence through the Java Persistence API 2. Support for light-weight domain modeling, including inheritance and polymorphism.
[ See EJB 3 specification JSR 220 ]

Previous Next


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code