< Zurück | Inhalt | Weiter >

Stateless Session Beans

What they are. A stateless session bean is one where each method call is completely independent of any other method call, whether by one or many clients.

An EJB application designed this way has certain advantages. Since a single Bean instance can be switched from client to client on demand (because no state information is kept between method invocations), a small number of Bean instances can handle a large number of clients. Compare this with stateful session beans described below.

Why you would use them. In a sense, this is the optimum bean. If you can design your application to use nothing but stateless session beans (perhaps backed by entity beans), then you have a maximally flexible, extensible, and adaptable enterprise application—one that can be easily scaled from a single application server to a very large cluster. Why? Because the lack of state infor- mation means that any single Bean instance can serve any given client at any

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.