Download
PDF
Home
History
PrevBeginningNext API
Search
Feedback
FAQ
Divider

What Is an Enterprise Bean?

Written in the Java programming language, an enterprise bean is a server-side component that encapsulates the business logic of an application. The business logic is the code that fulfills the purpose of the application. In an inventory control application, for example, the enterprise beans might implement the business logic in methods called checkInventoryLevel and orderProduct. By invoking these methods, remote clients can access the inventory services provided by the application.

Benefits of Enterprise Beans

For several reasons, enterprise beans simplify the development of large, distributed applications. First, because the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. The EJB container--and not the bean developer--is responsible for system-level services such as transaction management and security authorization.

Second, because the beans--and not the clients--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.

Third, because enterprise beans are portable components, the application assembler can build new applications from existing beans. These applications can run on any compliant J2EE server provided that they use the standard APIs.

When to Use Enterprise Beans

You should consider using enterprise beans if your application has any of the following requirements:

Types of Enterprise Beans

Table 23-1 summarizes the three types of enterprise beans. The following sections discuss each type in more detail.

Table 23-1 Enterprise Bean Types
Enterprise Bean Type
Purpose
Session
Performs a task for a client; implements a Web service
Entity
Represents a business entity object that exists in persistent storage
Message-Driven
Acts as a listener for the Java Message Service API, processing messages asynchronously

Divider
Download
PDF
Home
History
PrevBeginningNext API
Search
Feedback

FAQ
Divider

All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.