Whereas desktop JavaBeans usually run within a visual
container such as a form or a Web page, an enterprise bean runs within a container
provided by the application server.
The EJB container creates and manages enterprise bean instances at run-time,
and provides the services required by each enterprise bean running in it.
The EJB container supports a number of implicit services, including lifecycle,
state management, security, and transaction management:
- Lifecycle
- Individual enterprise beans do not need to manage process allocation,
thread management, object activation, or object passivation explicitly. The
EJB container automatically manages the object lifecycle on behalf of the
enterprise bean.
- State management
- Individual enterprise beans do not need to save or restore object state
between method calls explicitly. The EJB container automatically manages object
state on behalf of the enterprise bean.
- Security
- Individual enterprise beans do not need to authenticate users or check
authorization levels explicitly. The EJB container can automatically perform
all security checking on behalf of the enterprise bean.
- Transaction management
- Individual enterprise beans do not need to specify transaction demarcation
code to participate in distributed transactions. The EJB container can automatically
manage the start, enrollment, commitment, and rollback of transactions on
behalf of the enterprise bean.