结合无状态和无状态有状态连接
我的应用程序有一个无状态 EJB。现在我需要通过 Stateful 进行一些数据库操作。这个无状态 EJB 可以访问将打开有状态连接的数据库实用程序吗?这会导致任何设计/性能问题吗?
My application have a Stateless EJB. And Now I need to do some db operation via Stateful. Can this Stateless EJB can access the DB Utility which will open connection stateful? Will this lead to any design / performance Issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的意思是:
在第一种情况下,虽然可以在 StatelessSessionBean (SLSB) 前面使用 StatefulSessionBean (SFSB),但可能有更好的方法(例如,使用命令模式来收集远程调用之间的交互,直到您准备好犯罪)。
在第二种情况下,DataSource.lookup(用户名, 密码) 可能会有所帮助,尽管您的数据源查找可能需要一致地提供用户名和密码以保证接收相同的连接。
在这两种情况下,您都必须非常小心,不要犯基本的安全错误(例如以纯文本形式发送密码)。我从未使用过这两种方法,并且倾向于重新设计包含其中一种方法的解决方案。
我更担心性能问题,而不是安全性和其他设计问题,例如维护中的脆弱性。
Do you mean:
In the first case although it might be possible to do using a StatefulSessionBean (SFSB) in front of the StatelessSessionBean (SLSB), there are probably much better approaches (e.g. using the command pattern to collect the interactions between remote calls until you are ready to commit).
In the second case, DataSource.lookup(username, password) might help, although your DataSource lookups probably need to consistently provide the username and password to guarantee receiving the same connection.
In both cases you have to be very careful not to make basic security errors (like sending passwords in plain text). I've never used either approach and would be inclined to redesign a solution that included either.
I'd be less worried about performance issues than security and other design issues such as fragility under maintenance.