Enterprise beans are server-side J2EE components and run on the J2EE server in their EJB container which manages their execution. (Enterprise JavaBeans component model)
They handle the business logic of a J2EE application such as a web application. They contains the Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance.
An enterprise bean is a body of code with fields and methods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the J2EE server.
An enterprise bean:
in Enterprise JavaBeans terminology the installation process is called deployment.
There are three kinds of enterprise beans:
In contrast with a session bean, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved.
One of the benefits of entity beans is that you do not have to write any SQL code or use the JDBC API directly to perform database access operations. With container-managed persistence, database access operations are handled by the the EJB container, and your enterprise bean implementation contains no JDBC code or SQL commands. However, if you override the default container-managed persistence for any reason, you will need to use the JDBC API.
A message-driven bean combines features of a session bean and a Java Message Service (“JMS”) message listener, allowing a business component to receive JMS messages asynchronously.
A message-driven bean is an enterprise bean that allows Java EE applications to process messages asynchronously.
This type of bean normally acts as a JMS message listener, which is similar to an event listener but receives JMS messages instead of events.
The messages can be sent by any Java EE component (an application client, another enterprise bean, or a web component) or by a JMS application or system that does not use Java EE technology.
Message-driven beans can process JMS messages or other kinds of messages.
The most visible difference between message-driven beans and session beans is that clients do not access message-driven beans through interfaces.
Message-driven beans do not have interfaces or no-interface views that define client access.
Unlike a session bean, a message-driven bean has only a bean class.
Item | Syntax | Example |
---|---|---|
Enterprise bean name | nameBean | AccountBean |
Enterprise bean class | nameBean | AccountBean |
Business interface | name | Account |