微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无状态会话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?

原文地址:https://www.jb51.cc/java/129078.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐