EJB can be of the following types according to the EJB3 specification:
- Session bean:
- Stateful session bean
- Stateless session bean
- Singleton session bean
- Message-driven bean
We will discuss message-driven bean (MDB) in detail in a Chapter 10, Asynchronous Programming with JMS, when we learn about asynchronous processing of requests in the JEE application. In this chapter, we will focus on session beans.
In general, session beans are meant to contain methods to execute the main business logic of the enterprise application. Any Plain Old Java Object (POJO) can be annotated with the appropriate EJB3-specific annotations to make it a session bean. Session beans come in three types.