无状态会话bean中的实例变量

前端之家收集整理的这篇文章主要介绍了无状态会话bean中的实例变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已阅读此帖,但它没有回答我的问题.
Stateless session bean with instance variables
我正在阅读JEE5教程,并在此页面上说明
http://download.oracle.com/javaee/5/tutorial/doc/bnbly.html

但是,客户端可以更改池化无状态bean中的实例变量的状态,并且此状态将保留到池化无状态bean的下一次调用

我不同意这一点.因为我认为在不同的bean实例的调用中保持“任何”状态是你需要’有状态’的会话bean.

请帮我理解这个
提前thx
Rooban

解决方法

在EJB中,“有状态”和“无状态”之间的区别是指会话状态,而不仅仅是Java对象状态(即,实例字段的任何使用).

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.

典型的例子是电子商务应用程序的购物车.您使用SFSB来存储“cart”对象,因为它需要在请求之间保持对话状态.

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.

相关问题

> 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?

猜你在找的Java相关文章