如何删除 EJB2.1 无状态会话 bean
大家好, 我有一个问题:如何删除 EJB 会话 bean(尤其是无状态 bean)?
当然有remove()方法,但是当会话对象处于事务中时不能调用它,即会话bean A在其业务方法中被另一个会话bean B调用。
Greetings all,
I have a question: How to remove an EJB session bean (especially Stateless beans) ?
There's of course remove() method, however it cannot be called while the session object is in transaction i.e. session bean A is called by another session bean B in it's business method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无状态 bean 无法被客户端删除,事实上它们永远不会“消亡”,这是因为容器使用无状态会话 bean 池 em> 处理用户的请求。
仅当方法调用持续时,有状态 Bean 从池中取出并附加到客户端,之后,容器将其放回池中。奇怪的是,remove 方法仅适用于释放有状态 bean 和实体 bean 的资源,容器总是忽略无状态会话 bean 的remove 方法。
A Stateless bean can't be removed by the client, in fact they never "die", that's because the container uses a pool of stateless session beans to handle user's request.
A stateful bean is taken out from the pool and attached to a client only while the method call lasts, after that, the container put it back into the pool. Oddly, the remove method is only useful to realease resources for stateful and entity beans, the container always ignores the remove method for stateless session beans.