1、外文原文 The Basics of StatefulSession Beans Stateful session beans are conversational beans because they hold conversationswith clients that span multiple method invocations. Stateful session beans storeconversational state within the bean. That conversational state is specific to aparticular client. T
2、his chapter will teach you the basics of writing stateful sessionbeans. Well begin at the conceptual level and quickly move into a code exampleillustrating session bean development. Well wrap up with a comparisonof the stateful and stateless programming models. Characteristics of Stateful Session Be
3、ans Lets begin with a look at the characteristics that all stateful session beans share. Achieving the Effect of Pooling with Stateful Beans Imagine a scenario where thousands of clients are having conversations withdifferent stateful session beans running within a container. Lets assume thatthe cli
4、ents are typical clients and take a long time to think between methodcalls. Perhaps a client is far away, connecting from another country, and thenetwork lag is high. Or perhaps the client represents a human interacting witha Java applet, and the human is deciding on the next button to click.Thousan
5、ds of clients imply thousands of stateful session beans, each holdingconversational state on behalf of a specific client. And, of course, our EJB container/server has only a finite amount of resources available, such as memory,database connections, and socket connections. If the conversational state
6、 thatthe beans are holding is large, the container/server could easily run out of resources.This was not a problem with stateless session beans because the containercould pool only a few beans to service thousands of clients.With stateful session beans, pooling is not as simple. When a client invokes amethod on a bean, he or she is starting a conversation with the bean, and theconversational state stored in the bean must be available for that same clientsnext method request. Therefore, th