我们可以在J2EE应用程序中同时使用无状态和有状态会话bean吗? [英] Can we use both Stateless and Stateful session beans in a J2EE application?

查看:96
本文介绍了我们可以在J2EE应用程序中同时使用无状态和有状态会话bean吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果需求要求,对于不同的模块使用无状态和有状态会话bean是否是好方法?

Is it good way to use both Stateless and Stateful session beans for the different modules if the requirement demands ?

推荐答案

你问题很模糊,但看起来你基本上都在征求建议是否使用无状态或有状态会话bean是好的。

You question is quite vague, but it seems like you basically ask for advice whether it's good to use either stateless or stateful session beans.


  • 无状态会话bean(SLSB)最终易于使用。几乎没有什么可配置的,它们是公开服务的理想选择。

  • Stateless session beans (SLSB) are definitively easy to use. There is almost nothing to configure, and they are ideal to expose service.

有状态会话bean(SFSB)在表面上类似于SLSB。但事实上,他们的状态使他们的编程模型不同,并且更难使用。例如,您需要配置与您的负载匹配的池大小,设置超时参数,并且不要忘记正确处置它们。除非你确切知道为什么你会使用它们而不是另一种较轻的方法(例如 HttpSession 或数据库),否则人们通常会反对它,只有你掌握EJB模型。有关 Web应用程序中的有状态EJB 的更多信息。

Stateful session beans (SFSB) are superficially similar to SLSB. But the fact their are stateful make their programming model different, and are harder to use. For instance you will need to configure a pool size that matches your load, set the timeout parameter, and don't forget to dispose them correctly. People usually advice against it unless you know exactly why you would use them rather than another lighter approach (e.g. HttpSession, or database) and only if you have a good command of the EJB model. More info on Stateful EJBs in web app.

但是SLSB和SFSB当然可以在应用程序中一起使用。这项技术已经存在了十年,所以周围有大量的信息。然而,鼓励尝试使您的设计尽可能无状态。

But SLSB and SFSB can of course be used together in an application. The technology is around since one decade so there's plenty of information available around. It's however encouraged to try to make your design as stateless as possible.

这篇关于我们可以在J2EE应用程序中同时使用无状态和有状态会话bean吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆