Sunday, October 9, 2011

What are the different kinds of enterprise beans?



A session bean is a non-persistent object that implements some business logic running on the server,logical extension of the client program that runs on the server

There are two basic kinds of session bean: stateless and stateful

Stateless session bean- An instance of these non-persistent EJBs provides a service without storing an interaction or conversation state between methods. Any instance can be used for any client.Stateless beans are called stateless because they are transient

Stateful session bean- An instance of these non-persistent EJBs maintains state across methods and transactions. Each instance is associated with a particular client.Stateful beans are called "stateful" because they do maintain business state between method invocations, held in memory and not persistent. Unlike stateless session beans, clients do not share stateful beans

Entity bean- An instance of these persistent EJBs represents an object view of the data, usually rows in a database. They have a primary key as a unique identifier. Entity bean persistence can be either container-managed or bean-managed.It provides an object-oriented interface to data that would normally be accessed by the JDBC or some other back-end API.developers to focus their attention on the business logic of the bean, while the container takes care of managing persistence,transactions, and access control.

There are two basic kinds of entity beans: container-managed persistence (CMP) and bean-managed persistence (BMP).

container-managed persistence (CMP),all the logic for synchronizing the bean's state with the database is handled automatically by the container,the bean developer doesn't need to write any data access logic, while the EJB server is supposed to take care of all the persistence needs automatically

bean-managed persistence (BMP),The bean uses a database API to read and write its fields to the database, but the container tells it when to do each synchronization operation and manages the transactions for the bean automatically. Bean-managed persistence gives the bean developer the flexibility to perform persistence operations that are too complicated for the container or to use a data source that is not supported by the container.

Message-driven bean- An instance of these EJBs is integrated with the Java Message Service (JMS) to provide the ability for message-driven beans to act as a standard JMS message consumer and perform asynchronous processing between the server and the JMS message producer.




http://www.allapplabs.com/interview_questions/ejb_interview_questions_entity_beans.htm
http://www.techinterviews.com/j2ee-interview-questions-and-answers
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jst.ejb.doc.user/topics/cejb3vejb21.html