Loading...

EJB (Enterprise Java Beans)

EJB stands for Enterprise Java Beans. EJB is an essential part of a J2EE platform. J2EE platform has component based architecture to provide multi-tiered, distributed and highly transactional features to enterprise level applications. 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. EJB 3.0 is being a great shift from EJB 2.0 and makes development of EJB based applications quite easy.

Version History

EJB Version Release Date
EJB 4.0 22 May 2020
EJB 3.2.6 23 August 2019
EJB 3.2 28 May 2013
EJB 3.1 10 December 2009
EJB 3.0 11 May 2006
EJB 2.1 24 November 2003
EJB 2.0 22 August 2001
EJB 1.1 17 December 1999
EJB 1.0 24 March 1998

General Responsibilities

1. Transaction Processing.

2. Integration with the persistence services offered by the Jakarta Persistence (JPA).

3. Concurrency Control

4. Event-driven programming using Jakarta Messaging (JMS) and Jakarta Connectors (JCA)

5. Asynchronous method invocation

6. Job Scheduling

7. Naming and Directory Services via Java Naming and Directory Interface (JNDI)

8. Interprocess Communication using RMI-IIOP and Web services

9. Security (JCE and JAAS).

10. Deployment of software components in an application server.

Types of EJB

Session Bean stores data of a particular user for a single session. It can be stateful or stateless. It is less resource intensive as compared to entity bean. Session bean gets destroyed as soon as user session terminates.

Entity Bean represent 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.

Message Driven Bean are used in context of JMS (Java Messaging Service). Message Driven Beans can consumes JMS messages from external entities and act accordingly.

Session Bean

Session Bean encapsulates business logic only, it can be invoked by local, remote and webservice client. Session Bean can be used for calculations, database access etc. The life cycle of session bean is maintained by the application server (EJB Container).

Types of Session Bean

1. Stateless Session Bean doesn't maintain state of a client between multiple method calls.

2. Stateful Session Bean maintains state of a client across multiple requests.

3. Singleton Session Bean One instance per application, it is shared between clients and supports concurrent access.