SessionBean in JavaEE 6 Tutorail

A stateless session bean does not maintain a conversational state with the client. When aclient

invokes the methods of a stateless bean, the bean’s instance variables maycontain a state specific to

that client but only for the duration ofthe invocation. When the method is finished, the client-specific

state should not beretained. Clients may, however, change the state of instance variables in pooled

stateless beans,and this state is held over to the next invocation of thepooled stateless bean. Except

during method invocation, all instances of a stateless beanare equivalent, allowing the EJB container

to assign an instance to any client. Thatis, the state of a stateless session bean should apply across

allclients.Because they can support multiple clients, stateless session beans can offer better scalability

for applications that require large numbers of clients. Typically, an application requires fewerstateless

session beans than stateful session beans to support the same number ofclients.

A stateless session bean can implement a web service, but a stateful sessionbean cannot.

相关推荐