MVC Application Model Layer: Stateful and Stateless Session Beans

In the previous days, you have built two of the three layers of your Airline Ticket Booking System MVC application: the controller servlet and the view. The controller consists of a Java servlet that is used to control the flow and sequencing of actions in the application. The view layer is made up of JavaServer Pages. The data is passed from the controller to the view layer by wrapping it in the MVCAppValueObject. This ensures a degree of isolation between the two layers.

The third layer of the MVC application is the model. The model is where the business logic and data logic reside. The business-logic part of the model consists essentially of the transactional aspects of the application.

Stateful and stateless session beans can be used to represent the transactional functionality in the Airline Ticket Booking System application. From the class design, you can determine that two functions are primarily transactional in nature: user interactions, such as searching for available flights, creating a profile, viewing a profile, and so on; and the ticket-booking function.

Actions like searching for flights and user registration do not require state maintenance until the user logs in. Hence, you can model the user registration function with a stateless session bean. You will design and build the CustomerServiceAgentBean as the stateless session bean in the application.

The ticket-booking function and viewing profile represent the conversation between a user and a ticket-booking representative. Hence, a stateful session bean is more suitable for capturing the function of the ticket-booking representative. The TicketSalesAgentBean will perform the stateful session bean functions.

In order to understand the interaction of the session beans that form part of the model layer with the rest of the MVC application, take a look at Figure 11.10. The figure shows the sequence diagram of the Airline Ticket Booking System MVC application.

Figure 11.10. Sequence diagram of the Airline Ticket Booking System MVC application showing the Model (session bean) layer interactions.

graphics/11fig10.gif

The entire code of the CustomerServiceAgentBean and TicketSalesAgentBean is listed in Appendix C. This includes the listing for the home and remote interfaces of these beans.

You have now concluded building the transactional business-logic part of the model layer of your Airline Ticket Booking System MVC application. In the coming days, you will be building the data-logic parts of the model using entity beans.



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

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