使用 EJB 3.1 Singleton Bean 作为多个远程有状态会话 Bean 的客户端
我对 EJB 3.1 非常陌生,正在尝试解决服务器端问题;也许有人可以提供一些指导。
我有一个状态机,代表我的应用程序中多个用户的共享状态。我正在尝试将此状态机建模为有状态会话 Bean;由于此状态机代表多个用户,因此我引入了一个 Singleton Session bean,它是 StateMachine 的实际客户端,并且所有用户最终都成为 Singleton bean 的“客户端”。当我想在应用程序的整个生命周期中使用多个状态机的生命周期时,我的问题就出现了。
我希望我的 Singleton bean(“管理器”)能够处理客户端请求并分发到适当的 StateMachine - 我将如何访问该 Stateful bean 的特定实例?为了增加进一步的复杂性,我尝试远程访问这些 StateMachine beans(如果它是本地的,我只需创建这些东西的实例作为 Manager 的成员)。
无论如何,我希望这一点是清楚的。我觉得我错过了 EJB 设计的一些基本点;如果是这样的话,你们都会告诉我。
I'm very new to EJB 3.1 and am trying to solve a server side problem; perhaps someone could offer some guidance.
I have a state machine that represents the shared state of multiple users in my application. I'm attempting to model this state machine as a Stateful Session Bean; since there are multiple users represented by this State Machine, I introduced a Singleton Session bean that is the actual Client of the StateMachine and all of the users end up being "Clients" to the Singleton bean. My problem arises when I want to lifecycle multiple StateMachines throughout the life of the Application.
I would like my Singleton bean (the "Manager") to handle client requests and distribute to the appropriate StateMachine - how would I access specific instances of that Stateful bean? To add further complexity, I'm trying to access these StateMachine beans remotely (if it were local, I'd just create instances of these things as members of the Manager).
Anyway, I hope this is clear. I feel like I'm missing some fundamental point of EJB design; y'all will tell me if that's the case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
EJB 3.1 中引入了单例,提供了在多个实例之间共享状态的能力,如 EJB 示例中所述3.1。
查看Java EE6 事件了解如何使用事件发送通知。
Singletons have been introduced in EJB 3.1 providing the ability to share state between multiple instances as described in A Sampling of EJB 3.1.
Have a look at Java EE6 Events about how to send notifications using events.