Most Popular Posts

Showing posts with label ejb. Show all posts
Showing posts with label ejb. Show all posts

09/04/2013

What is - EJB - Enterprise Java Bean


TL;DR

EJB - Enterprise Java Beans is a server-side components written in Java programming language that encapsulate business logic of an application.

Types of EJBs: Session, Entity, Message-Driven




Details:


Properties of EJBs:

  • EJB has distributable and deployable business logic to clients
  • EJB is reusable across application servers
  • EJB executed within container that provides management and control services

EJB Modules contain: 
class files for enterprise beans, and EJB DD (Deployment Descriptors). Such modules are packed as JAR files.


There are three types of EJBs:


  • Session
  • Entity
  • Message-driven (v 2.0)


Session EJBs
Session EJB is an object, non-persistent, that lives only between client and EJB. If the user fails to remove the session EJB, it will be removed after a period of time. In order to share the sessions between the clients, we have two types of session EJBs:

  • Stateful - addressed for particular client
  • Stateless - shared among all the clients

Entity EJBs (deprecated)
Entity EJBs are for persistent objects. These are mainly used for mapping DBs with applications. 
Its persistence is delegated to the EJB container or is managed on its own. 
In EJB 3.0, entity beans were superseded by the Java Persistence API (which was subsequently completely separated to its own spec as of EJB 3.1). Entity Beans have been marked as a candidate forpruning as of Java EE 6 [1][2] and are therefore considered a deprecated technology.

Source: http://en.wikipedia.org/wiki/Entity_Bean

Message-Driven EJBs

Message driven beans collect/ retrieve messages in asynchronous mode. When message arrives it usually triggers particular function. Clients can subscribe to specific topics and be informed upon message arrival.