Enterprise beans
An enterprise bean is a Java component that can be combined with other resources to create J2EE applications.
All beans reside in EJB containers, which provide an interface between the beans and the appserver on which they reside.
Beans that require data access use data sources for connections to persistent storage mechanisms.
There are three types of enterprise beans
- Entity beans
Store permanent data. Entity beans with container-managed persistence (CMP) require connections to a form of persistent storage. This storage might be a database, an existing legacy application, a file, or another type of persistent storage. Entity beans with bean-managed persistence manage permanent data in whichever manner is defined in the bean code. For example, they can write data to databases or XML files
- Session beans
Do not require database access, although they can obtain it indirectly as needed through entity beans. Session beans can also obtain direct access to databases (and other resources) through the use of resource references. Session beans can be either stateful or stateless.
- Message-driven beans.
Enable asynchronous message servicing. The EJB container and a JMS provider work together to process messages. When a message arrives from another application component through JMS, the EJB container forwards it through an onMessage() call to a message-driven bean instance, which then processes the message. In other respects, message-driven beans are similar to stateless session beans.