CONTENTS | PREV | NEXT | INDEX J2EE BluePrints



5.6 Summary

There are a number of common services that distributed enterprise applications require. These include maintaining state, operating on shared data, participating in transactions, servicing a large number of clients, providing remote access to data, and controlling access to data. The middle tier of enterprise computing has evolved as the ideal place to provide these services. The J2EE platform promotes the Enterprise JavaBeans architecture as a way to provide the system services that most enterprise applications need. The EJB architecture frees enterprise application developers from concerns about these services enabling them to concentrate on providing business logic.

The Enterprise JavaBeans architecture provides various types of enterprise beans to model business objects: entity beans, stateful session beans, and stateless session beans. When choosing a particular enterprise bean type to model a business concept, the choice depends on a number of factors such as the need to provide robust data handling, the need to provide efficient behavior, and the need to maintain client state during a user session.

An entity bean provides an object-oriented view of relational data stored in a database; a stateless session bean gives a procedural view of the data. An Application Component Provider should use entity beans to model logical entities such as individual records in a database. When implementing behavior to visit multiple rows in a database and present a read-only view of data, stateless session beans are the best choice. They are designed to provide generic services to multiple clients.

Some business concepts actually require more than one view of data. An example would be a catalog that provides browsing and searching services as well as mechanisms to update the product information. In such cases, you can use a stateless session bean to operate on a product information as a whole and an entity bean to provide access to a particular product.

Because enterprise beans are remote objects that consume significant amount of system resources and network bandwidth, they are not appropriate for modeling all business objects. An Application Component Provider can use data access objects to encapsulate database access and value objects to model objects that are dependent on enterprise beans.

Also, it may not be appropriate to give clients direct access to all enterprise beans used by an application. Some enterprise beans may act as mediators for communication between clients and the EJB tier. Such beans can encapsulate work flow specific to an application or can serve as an entry point to a hierarchy of information.



CONTENTS | PREV | NEXT | INDEX
Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.