02 - Types of EJBs

Types of EJBs

EJB 3 specification defines 3 types of beans:

  1. Session beans
  2. Message driven beans  
  3. Entity beans

For the first type, Session beans, it contains all the required business logic. The developer implements all business rules in this type of beans and requests are served synchronously using session beans, and there two types of session beans: Stateless and Stateful. A stateless session bean does not store any session information. For example, a link the web application that generates a certain pdf report can be implemented using a stateless session bean. On the other hand, a Stateful session bean retains session information during an interaction between a specific client and the server.

A message driven bean has been introduced in the EJB 3 specification to handle asynchronous message calls using JMS queues.

Entity beans are the persistence units. Usually each entity bean represents a database table and each instance is a database record.

With all these features and capabilities, EJB may seem cumbersome and hard to learn. Typically, EJB is not an easy task to learn, however, it’s not rocket science! In the following chapters we will explore most of EJB 3.2 features in details and we will provide a case study that wraps everything up.

Like us on Facebook