Java Reference
In-Depth Information
time that it is free without requiring any distribution of client information
between Bean instances.
From the client's perspective, the client can connect to any instance of the
Bean on any server at any time to get the same work done.
Stateful Session Beans
What they are. A stateful session bean is one that remembers its client be-
tween method invocations. It maintains some information between calls from
a client. Because of this, a given Bean instance can only handle one client at a
time, and if an instance is to be switched between clients, the information
about the previous client must be saved so that the client's session may be
restored later.
An application that is designed around stateful session beans will generally
require more resources than one designed around stateless session beans
(described above) because each active client requires a dedicated instance of
the Bean .
Why you would use them. We think we've beaten the issue of the advan-
tages of stateless beans into the ground. But what are the advantages of a
stateful bean?
Many types of client interaction require the bean to “remember” some-
thing about the client. The classic (and, by now, almost cliché) example is a
Web-based shopping cart application. The remote interface for a stateful
ShoppingCart EJB might look something like this:
createCart
Creates a new shopping cart for the customer.
addItem
Adds an item to the shopping cart.
delItem
Removes an item from the shopping cart.
purchaseCart
Processes the cart; charges the credit card; generates pick list, shipping list,
and invoice; discards cart.
abandonCart
Discards the cart.
Search WWH ::




Custom Search