servlet 中 ejb3 注入的并发含义是什么?
我想将 ejb3 注入与 jndi 查找方法进行对比,注入是否将代理的 1 个特定实例绑定到 servlet?如果是这样,那么在集群环境中,如此严格的运行时绑定可能会导致效率低下。
i want to contrast ejb3 injection with the jndi lookup method, does injection bind 1 particular instance of proxy to the servlet ?? If so , then in a clustered environment such tight runtime binding could lead to inefficiencies .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于无状态,EJB 代理与其支持实例(通常是池化的)是一对多的,并且可以安全地注入到 servlet 中。
对于 Singleton,EJB 代理与其支持实例是一对一的,但容器(或 bean)负责确保并发调用是安全的还是不允许的,具体取决于每个方法的业务逻辑。 @AccessTimeout 可用于控制等待锁的时间。
对于有状态,EJB 代理与其支持实例是一对一的,并且不能安全地注入到 servlet 中。从 EJB 3.1 开始,有状态会话 bean 并发性提供了一定的安全性,但由于有状态会话 bean 超时,将有状态会话 bean 注入到 servlet 中不太可能有用。
For Stateless, an EJB proxy is 1-to-many with its backing instances (usually pooled) and is safe to inject into a servlet.
For Singleton, an EJB proxy is 1-to-1 with its backing instance, but the container (or bean) is responsible for ensuring the concurrent calls are either safe or disallowed, depending on business logic of each method. @AccessTimeout can be used to control how long to wait for a lock.
For Stateful, an EJB proxy is 1-to-1 with its backing instance and is not safe to inject into a servlet. As of EJB 3.1, stateful session bean concurrency allows some safety, but due to stateful session bean timeouts, injecting a stateful session bean into a servlet is unlikely to ever be useful.