开发者

instance variables in stateless session beans

I have read this post and it doesn't answer my question. Stateless session bean with instance variables I am reading the JEE5 tutorial and on this page it states http://download.oracle.com/javaee/5/tutorial/doc/bnbly.html " Clients may, however, change the state of instance variables in pooled stateless beans, and this state is held over to the next invocation of the pooled stateless bean "

I don't agree with this.. coz i thought keeping 'any' kind of state across invocations of different instanc开发者_如何转开发e of beans was something you need 'stateful' session beans for.

Please help me understand this thx in advance Rooban


In EJB the distinction between "stateful" and "stateless" refers to conversational state, not simply Java object state (that is, any use of instance fields).

From Wikipedia:

In a stateful session bean, the instance variables represent the state of unique client-bean sessions. The interaction of the client with bean is called as conversational state.

The classic example is that of a shopping cart for an ecommerce application. You'd use a SFSB to store the "cart" object because it needs to maintain conversational state between requests.

On the other hand:

A stateless session bean is an object that does not have an associated conversational state, but may have instance state. It does not allow concurrent access to the bean. The contents of instance variables are not guaranteed to be preserved across method calls. All instances of a stateless session bean should be considered identical by the client.

Related questions

  • Stateless and Stateful Enterprise Java Beans
  • Stateful EJBs in web application?
  • Correct usage of Stateful Beans with Servlets
  • Static vs Instance members in Stateless EJBs
  • Why use stateful session beans?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜