Search This Blog

Saturday, 13 September 2014

Types of Enterprise Beans J2EE-7

Enterprise Beans(Jee-7)

An Enterprise Bean is a server-side component that encapsulates business logic.

Types of Enterprise Beans:

There are 2 types of Enterprise beans:

  • Session Bean 
  • Message-Driven Bean
    A session Bean is used to perform a task for a client optionally as a web service, which is again classified as 

  1. Stateless session bean
  2. Stateful session bean
  3. Singleton session bean

1. stateless session bean:

A stateless session bean does not maintain a conversational state with the client. The bean's instance variables may contain a state but only during the method invocation.

use stateless session bean if you want the bean to perform a common task for all the clients. For example, sending an email for conforming a shopping order.

2. Stateful session bean:

A stateful session bean maintains a conversational state with a specific client during the session, until client terminates the session. Once the client terminates the session then the state is no longer maintained.

use stateful session bean if a user/client information is needed across methods invocations. Stateful session beans also manages the workflow of several enterprise beans.

A stateful session bean cannot implement a web service.

3. Singleton session bean:

A singleton session bean is instantiated once per application and exists for a life-cycle of the application.

Applications implementing singleton session bean is allowed to be instantiated at the application start-up, which performs any initialization tasks required for the application. It can also be used at the shutdown of the application since it can be available and accessed through out the life-cycle of the application. 

A singleton can implement a web service.

Message-Driven Beans: 

Message-Driven Beans listens for messaging types, such as Java Messaging Service API.

No comments:

Post a Comment