What are the different types of enterprise beans available in EJB 3.x?
What are the different types of enterprise beans available in EJB 3.x?
There are two types of enterprise beans defined in EJB 3.x:
-
- Session Bean – Performs a task for a client, encapsulates the business logic of the application. Session beans are of three types:
(a). Stateless Session Bean: A stateless session bean does not maintain a conversational state with the client. When a client invokes the methods of a stateless bean, the bean’s instance variables may contain a state specific to that client but only for the duration of the invocation. When the method is finished, the client-specific state should not be retained.
(b). Stateful Session Bean: In a stateful session bean, the instance variables represent the state of a unique client/bean session. If the client completes all the operations on the bean, the session ends and the state disappears.
(c). Singleton Session Bean: A singleton session bean is instantiated once per application and exists for the lifecycle of the application. Singleton session beans are designed for circumstances in which a single enterprise bean instance is shared across and concurrently accessed by clients.
-
- Message Driven Bean – Acts as an asynchronous message consumer. This type of bean normally acts as a JMS (Java Message Service) message listener.