Stateless Session Bean

Stateless Session Bean - INTERNATIONAL INSTITUTE OF...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
P-14, Pune Infotech Park, Hinjawadi, Pune – 411 057 Creating Stateless Session Beans Yesterday, you gained an understanding of Enterprise JavaBeans (EJBs) and studied the first type of EJB, the stateful session bean. Yesterday’s lesson also covered concepts such as components of a stateful session bean, the stateful session bean life cycle, and steps involved in building and deploying stateful session beans. You wrote a sample application that modeled the functions and activities in a restaurant with the customer, waiter, and chef as the primary actors. This example made you aware of how real-life entities can be easily modeled into EJBs and helped you identify the EJB to which these entities are mapped based on their activities (whether state maintenance is required or not required, and so on). Today you will be looking at the other type of session EJB, the stateless session bean. You will be covering concepts such as the life cycle of stateless session beans, their components, and so on. Also, you will be converting the chef classes of the restaurant application from yesterday into a stateless session bean. In addition to this, you will be covering concepts about accessing a stateless session bean from a CORBA or RMI client. The final part of the day will be devoted to building the transactional parts of the MVC Airline Ticket Booking System application as stateful and stateless session beans. Life Cycle of a Stateless Session EJB The life cycle of a stateless session bean varies from the life cycle of a stateful session bean. Figure .1 shows that the life cycle of a stateless session bean is fairly simple. There are three stages in the life cycle of a stateless session bean: creation, process operations, and termination. Creation Similar to a stateful session bean, the stateless session bean is created by the EJB container as a new instance of the stateless session bean after the client application invokes the create() method on the home interface of the stateless session bean. As a part of the creation process, the setSessionContext() method of the stateless session bean is invoked by the EJB container. The final step in the creation of a stateless session bean is the EJB container’s invoking the ejbCreate() callback method on the bean instance. Because no state information about the client application is maintained by the stateless session bean, the ejbCreate() method is not overloaded and does not need to have any state information passed as parameters to the ejbCreate() method. This is a significant difference from a stateful session bean, in which the state information of the client application was passed as parameters to the ejbCreate() method and stored in the instance of the stateful session bean. After invoking the ejbCreate() method, the reference of the remote object of the stateless session bean is returned to the client application. The client application uses this remote object reference to invoke business methods published in
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

Stateless Session Bean - INTERNATIONAL INSTITUTE OF...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online