Tuesday, September 29, 2015

Study About Enterprise Java Beans (EJB) Introduction

Enterprise Java Beans (EJB) is a development architecture for building highly scalable and robust enterprise level applications to be deployed on J2EE compliant Application Server such as JBOSS, Web Logic etc.

A recent study by Java developer Raghu Kodali has shown that porting Sun's Java EE tutorial application RosterApp from EJB 2.1 to EJB 3.0 resulted in
more than a 50-percent reduction in code and The development of EJB 3 is faster than EJB 2 because of simplicity and annotations such as @EJB, @Stateless, @Stateful, @ModelDriven, @PreDestroy, @PostConstruct etc.

An EJB application can be deployed on any of the application server such as Jboss, Glassfish, Weblogic, Websphere etc compliant with J2EE 1.3 standard specification.It performs:
  • life cycle management,
  • security,
  • transaction management, and
  • object pooling.
EJB are primarily of three types which are briefly described below:

Type Description
Session Bean Session bean contains business logic that can be invoked by local, remote or web service client. It can be stateful or stateless. It is less resource intensive as compared to entity beans. Session bean gets destroyed as soon as user session terminates.
Entity Bean Entity beans represents persistent data storage. User data can be saved to database via entity beans and later on can be retrieved from the database in the entity bean.It is deprecated. Now, it is replaced with JPA (Java Persistent API).
Message Driven Bean Message driven beans are used in context of JMS (Java Messaging Service). Message Driven Beans can consumes JMS messages from external entities and act accordingly.