Enterprise Beans
Enterprise
beans are Java EE components that implement Enterprise JavaBeans (EJB)
technology. Enterprise beans run in the EJB container. The EJB container
provides system-level services, such as transactions and security, to its
enterprise beans
What Is an Enterprise Bean?
An
enterprise bean is a server-side component that encapsulates the business logic
of an application. The business logic is the code that fulfils the purpose of
the application.
For Example :
In an
ecommerce site the enterprise beans might implement the business logic in
methods called checkOut and orderProduct. By invoking these methods, clients can
access the services provided by the application.
Benefits of Enterprise Beans
Enterprise
beans simplify the development of large, distributed applications.
- The EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. The EJB container, rather than the bean developer, is responsible for system-level services, such as transaction management and security authorization.
- The beans contain the application’s business logic, the client developer can focus on the presentation of the client. The client developer does not have to code the routines that implement business rules or access databases. As a result, the clients are thinner, a benefit that is particularly important for clients that run on small devices.
- Enterprise beans are portable components, the application assembler can build new applications from existing beans. Provided that they use the standard APIs, these applications can run on any compliant Java EE server.
When to Use Enterprise Beans
- The application must be scalable.
- Transactions must ensure data integrity. Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects.
- The application will have a variety of clients.
There are two types of enterprise beans.
- Session Beans : Performs a task for a client; optionally, may implement a web service
- Message-driven Beans : Acts as a listener for a particular messaging type, such as the Java Message Service API