结合无状态和无状态有状态连接

发布于 2024-08-03 09:01:52 字数 98 浏览 3 评论 0原文

我的应用程序有一个无状态 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷弦 2024-08-10 09:01:52

哪个将打开有状态连接?

您的意思是:

  1. 打开一个有状态连接,该连接将在对服务器的调用之间保持打开状态,并且在返回客户端时不会自动提交?
  2. 使用会话上下文中可用的安全凭证打开连接,以获取与用户自己的数据库用户/密码的连接?

在第一种情况下,虽然可以在 StatelessSessionBean (SLSB) 前面使用 StatefulSessionBean (SFSB),但可能有更好的方法(例如,使用命令模式来收集远程调用之间的交互,直到您准备好犯罪)。

在第二种情况下,DataSource.lookup(用户名, 密码) 可能会有所帮助,尽管您的数据源查找可能需要一致地提供用户名和密码以保证接收相同的连接。

这会导致任何设计/性能问题吗?

在这两种情况下,您都必须非常小心,不要犯基本的安全错误(例如以纯文本形式发送密码)。我从未使用过这两种方法,并且倾向于重新设计包含其中一种方法的解决方案。

我更担心性能问题,而不是安全性和其他设计问题,例如维护中的脆弱性。

which will open connection stateful?

Do you mean:

  1. Open a stateful connection that will stay open between calls to the server and not commit automatically when returning to the client?
  2. Open a connection using the security credentials available from the session context to obtain a connection with the user's own database user/password?

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.

Will this lead to any design / performance Issue?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文