CHOOSING ENTITY BEANS OR STATEFULSESSION BEANS
Now, we will learn when and where we should use entity beans or stateful session beans. The architect of the application chooses how to map the business entities and processes to
enterprise beans. No prescriptive rules dictate whether a stateful session bean or an entity bean should be used for a component: Different designers may map business entities and processes to enterprise beans differently.
We can also combine the use of session beans and entity beans to accomplish a business task. For example, we may have a session bean represent an ATM withdrawal that invokes an entity bean to represent the account.
The following guidelines outline the recommended mapping of business entities and processes to entity and session beans. The guidelines reflect the life-cycle differences between the session and entity objects.
• A bean developer typically implements a business entity as an entity bean.
• A bean developer typically implements a conversational business process as a stateful session bean. For example, developers implement the logic of most Web application sessions as session beans.
• A bean developer typically implements, as an entity bean a collaborative business process: a business process with multiple actors. The entity object's state represents the intermediate steps of a business process that consists of multiple steps.
For example, an entity object's state may record the changing information state on a loan application as it moves through the steps of the loan-approval process. The object's state may record that the account representative entered the information on the loan application, the loan officer reviewed the application, and application approval is still waiting on a credit report
If, it is necessary for any reason to save the intermediate state of a business process in a database, a bean developer implements the business process as an entity bean. Often, the saved state itself can be considered a business entity. For example, many e-commerce Web applications use the concept of a shopping cart, which stores the items that the customer has selected but not yet checked out. The state of the shopping cart can be considered to be the state of the customer shopping business process. If, it is desirable that the shopping process span extended time periods and multiple Web sessions, the bean developer should implement the shopping cart as an entity bean. In contrast, if the shopping process is limited to a single Web
session, the bean developer can implement the shopping cart as a stateful session bean.
session, the bean developer can implement the shopping cart as a stateful session bean.
No comments:
Post a Comment