Chapter 15 Developing session beans JBuilder s EJB tools

Chapter 15 Developing session beans JBuilder s EJB tools can greatly simplify the creation of enterprise beans and their supporting interfaces. You should understand what the requirements are for these classes and interfaces, however, so you can modify the files JBuilder produces and so you understand what JBuilder is doing for you. The next few chapters can help you gain that understanding. A session bean usually exists for the lifetime of a single client session. The methods of a session bean perform a set of tasks or processes for the client that uses the bean. Session beans persist only for the life of the connection with the client. In a sense, the session bean represents the client in the EJB server. It usually provides a service to the client. Unless you need to work with persistent data that exists in a data store, you are usually working with session beans. Types of session beans There are two types of session beans: those that can maintain state information between method calls, which are called stateful beans, and those that can t, which are called stateless beans. Stateful session beans Stateful session beans are objects used by a single client and they maintain state on behalf of that client. For example, consider a shopping cart session bean. As the shopper in an online store selects items to purchase, the items are added to the shopping cart by storing the selected items in a list within the shopping cart session bean object. When the shopper is ready to purchase the items, the list is used to calculate the total cost. Stateless session bean Stateless session beans don t maintain state for any specific client. Therefore, they can be used by many clients. For example, consider a sort session bean that contains a sortList() business method. The client would invoke sortList(), passing it an unsorted list of items. sortList() would then pass back to the client a sorted list. Chapter 15: Developing session beans 149
Don’t want to have just any web hosting, but web hosting provider who will share the same beliefs? You have found them. Our Church Web Hosting company will treat in you in appropriate way, the one you are accustomed to.

Leave a Reply