Stateful EJBs in web application
来源:互联网 发布:奥迪a4l矩阵大灯 编辑:程序博客网 时间:2024/06/04 00:42
in which case to use them on a web application?
The traditional example of SFSB and web app is the shopping cart. But at the same time, you can do the same with the HttpSession
.
Ideally, if the state relates to the business logicand not the presentation logic, it should go in a SFSB. But inpractice, people usually advocates against SFSB (because of thecomplexity it introduces) unless they provide something you can not doeasily with the HttpSession
. Most of the time, you can tweak the design to store the information in the HttpSession
or the database and pass it around, without the need to have SFSB. But it's ultimately a question of design purity.
And how? Should we put these stateful beans in Session (because of stateless http)?
The EJB model is a richer model than the HttpSession
,because EJB are transactional components, and there are explicitcallbacks for the passivation and activation of SFSB. This comes withan increased complexity about how to use SFSBcorrectly, notably (1) exception handling and (2) concurrency and (2)removal and time-out of SFSB. See my answers here for more details:
- Java: Tracking a user login session - Session EJBs vs HTTPSession
- Correct usage of Stateful Beans with Servlets
If you want to use them, you will need first to look up the SFSB toget a reference to one fresh remote instance. Then you will need tostore this reference somewhere in a way to reuse it across requests.This somewhere is usually the HttpSession
, which means that even if you use SFSB, you can't get rid of it completely.
With EJB2, the remote reference -- called a handle -- couldbe serialized to be reused later. It was then possible to store if forinstance in database, even though I've never seen that. I don't know ifit's still possible with EJB3.
Is it a good practice?
As I said already, people usually advice against it unless you know exactly why you would use them rather than the HttpSession
and only if you have a good command of the EJB model. (SFSB could bejustified for instance if the business service is accessible through aweb front-end and a desktop client) Lots of other frameworks don't have something similar as SFSB and people still manage to create great apps with them.
- Stateful EJBs in web application
- Servlet In Web Application
- Charset in J2EE Web Application
- Privilege Management in Web Application
- 18.2 Log4J in a Web Application
- Add web application project in VS 2005
- watir语法(Web Application Testing in Ruby)
- WatiN: Web Application Testing In .Net!
- Watir 语法(Web Application Testing in Ruby)
- Portal event in Web dynpro application
- using Camel in a Web Application
- Parse error in application web.xml
- android in practice_Managing a stateful list/Header and footer views
- State in Flink and Rescaling Stateful Streaming Jobs
- Using the Web Service Callbacks in the .NET Application
- Creating a Simple Web Application in NetBeans Using MySQL(1)
- How to use AspnetUpload™ in your web application
- Adobe Alchemy - Reusing C/C++ in Web application
- 读“重构-改善既有代码的设计”一书重点摘要
- 程序人生之二 IoC—如何才能快乐
- 20000条笑话保证笑死你
- 在表单里使用excel工作表
- 请问如何判断一个窗口是否处于隐藏状态?
- Stateful EJBs in web application
- FLASH与ASP通信入门教程 LV类基础讲解
- 在VMWare ESX4.1/Sever 2中以 CentOS5.5 安装 Oracle 11.2 RAC
- VC++数据类型转换
- sqlserver2000升级到2005总结
- Asp.Net中不修改IIS实现URL重写,支持任意扩展名及无扩展名(伪静态)
- sql 分段统计
- MSSQL 2005数据库不能正常连接:客户端无法建立连接,因为在登录前连接初始化进程中发生错误
- JAVA JNA