Chapter 7. Understanding Entity Beans

An entity bean is a component that encapsulates the implementation of a business entity or a business process. The encapsulation of a business entity or process is typically independent of the client application that uses the entity bean. As a result, an entity bean can be reused by many client applications.

This chapter focuses on the basics of entity beans from a programming point of view. The chapter describes the client view of an entity bean the view of the application developer who uses an entity bean and the view of the developer of the entity bean itself. We also describe the life cycle of entity bean class instances and show how the container manages the instances at runtime.

Clients of entity beans, similar to session bean clients, use the methods of the home and component interfaces. However, because the life cycles of an entity object and a session object differ, an entity bean client takes a different approach to using the home interface methods for creating and removing entity objects. In addition, each entity object has a unique identity, which allows the home interface to define find methods for locating entity bean instances.

A bean developer must write the implementation of the entity bean's business logic in addition to the life-cycle-related methods. The bean developer is also concerned about entity object persistence. The state of an entity object is stored in a resource manager, such as a database or other persistent storage. The entity bean methods access the state in the resource manager, using either container-managed persistence (CMP) or bean-managed persistence (BMP).

This chapter also explains how the container manages entity bean instances. Although not all developers need to know this information, it is interesting to see what happens beneath the surface during the various method invocations, passivation and activation, and transactions.



Applying Enterprise Javabeans
Applying Enterprise JavaBeans(TM): Component-Based Development for the J2EE(TM) Platform
ISBN: 0201702673
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net