Java architectures #2 – EJB

Enterprise Java Beans 2.0

EJB were and still are a J2EE API to implement business logic for distributed applications, these superseed traditional Java Beans with support remote calls, transactions and persistence for applications,

Enterprise Beans were deployed in EJB containers and run on EJB servers , application servers that support J2EE full specification, eg: Websphere, JBoss, Glassfish.

There are three types of of EJB’s [2]:

  • Session beans, non persistent beans. that can be 1) Stateful session beans: can maintain client specific session information across multiple methods calls and transactions. 2) Stateless session beans: doesn’t not maintain conversational state.

  • Entity beans: beans that contain persistent data and that can be saved in persistent stores. Entity beans that manage their own persistence are called bean-managed persistence (BMP) entity beans. Entity beans that delegate their persistence to their EJB container are called container-managed persistence (CMP) entity beans.
  • Message-driven beans: Message-driven beans are enterprise beans that receive and process JMS messages.

Main EJB framework components [1]

A client accesses a session bean or an entity bean through the bean’s home and component interfaces, home and component interfaces of the bean provide the client view.

The container provides classes that implement the enterprise bean’s home and component interfaces.

There are two types of clients [3]:

Remote clients: A remote client accesses a session bean or an entity bean through the bean’s remote interface and remote home interface. The remote and remote home interfaces of the bean provide the remote client view.

Local clients: A local client is a client that is collocated in the same
JVM with the session or entity bean that provides the local client view.

EJB was a part of J2EE eco-system and would integrate with the remaining technologies to provide a full spectrum of solution for Enterprise world.

EJB integrations with Web/JSP

EJB 2.0 purpose was to create reusable components and thus make development more easier, but it was deem to complex and cumbersome, ironically Spring Framework come as an alternative to EJB using POJO.

This release of EJB was replaced by EJB 3.0, much simpler and very similar to Spring Framework

[1] https://www.oreilly.com/library/view/ejb-20-development/0738426091/0738426091_ch02lev1sec3.html

[2] https://www.ibm.com/support/knowledgecenter/SS8PJ7_9.7.0/org.eclipse.jst.ejb.doc.user/topics/cearch.html

[3] http://webarchiv.ethz.ch/dbs/education/oho/SS_02/additional-info/ejb-2_0-fr2-spec.pdf