我们应该如何关注JSF托管bean的线程安全性? [英] How concerned should we be about thread safety with JSF managed beans?

查看:192
本文介绍了我们应该如何关注JSF托管bean的线程安全性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个JSF 1.2项目,它在页面上有AJAX功能(使用RichFaces)。

I'm working on a JSF 1.2 project which has AJAX functionality on it's pages (using RichFaces).

我的bean构建了一个要编辑的对象列表,然后有方法来支持编辑,bean是会话范围的。我将使用一个a4j:队列,这样一次只能发生一次AJAX调用。

My bean builds a list of objects to be edited and then has methods to support the editing and the bean is session-scoped. I will be using a a4j:queue so that only one AJAX call can happen at a time.

我很好奇是否明智地使用同步(锁定对象) ,或者托管bean中的java.util.concurrent集合。真正需要实现同步/线程安全所需的额外工作吗?我正在开发的网站有很多用户,需要可靠但是它有很多托管bean,我很好奇我应该关注托管bean整体的线程安全性。

I'm curious if it is wise to use synchronization (locks on objects, or perhaps collections from java.util.concurrent) in the managed bean. Is the extra work needed to implement synchronization/thread safety really needed? The site I am working on has many users and needs to be reliable but it has a LOT of managed beans, and I'm curious how concerned I should be about the thread safety of managed beans overall.

在支持bean的线程安全方面采取了额外的步骤吗?

Do you take extra steps in backing beans for thread-safety?

提前致谢。

推荐答案

a4j:队列不会阻止用户在AJAX调用过程中重新加载页面/点击其他链接。

a4j:queue won't prevent the user from reloading the page / clicking another link while the AJAX call is in progress.

是的,我们可能会相信用户不会一个接一个地点击许多不同的链接,但是用户不会触发的请求呢,例如a4j:poll?

Yes, we can probably trust the user not to click many different links right after each other, but what about requests not triggered by the user, for instance by a4j:poll?

请注意,用线程安全的等效项替换所有集合可能不足以使应用程序线程安全。

Note that replacing all collections with their thread-safe equivalent might not be enough to make your application thread safe.

这就是说,根据您的应用程序需要满足的可靠程度,这个问题可能会或可能不值得您关注。

That said, depending on the degree of reliability your application needs to meet, this problem might or might not deserve your attention.

这篇关于我们应该如何关注JSF托管bean的线程安全性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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