为什么池无状态的bean? [英] why pool stateless bean?

查看:113
本文介绍了为什么池无状态的bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我们在business / dao层使用单例实例。在EJB的情况下池无状态会话bean的原因是什么?

解决方案

名称中的无状态是指会话对话状态,即在调用bean之间持续的状态,在会话期间保留。然而,无状态会话bean仍然允许具有实例变量。这些实例变量不应该与会话状态相关,而是在客户端之间共享。



换句话说,无状态会话bean不能保证线程安全。 >

因此,容器应该确保一次只有一个线程正在执行无状态会话bean的给定实例,因此需要一个池。


Normally we use singleton instance for business / dao layer. What is the reason behind pooling stateless session beans in case of EJBs?

解决方案

The "stateless" in the name refers to session conversation state, i.e. state that persists between invocations of the bean, retained for the duration of the session. However, stateless session beans are still permitted to have instance variables. Those instance variables should not relate to the conversation state, but are "shared" between clients.

In other words, stateless session beans are not guaranteed thread safe.

As a result, the container should ensure that only one thread is executing a given instance of a stateless session bean at one time, hence the need for a pool of them.

这篇关于为什么池无状态的bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆