JSF调整 [英] JSF Tuning

查看:106
本文介绍了JSF调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遇到JSF填满我们会话的问题。前几天我们遇到了系统崩溃。发送堆给IBM进行审核,发现我们有一些大到50M的会话。他们在会话中发现了JSF组件,而且有些非常大。

Running into an issue where JSF is filling up our sessions. We had a system crash the other day. Sent the Heap to IBM for review and found that we had some sessions as large as 50M. They found JSF components in the session and some very large.

那么,有没有可以完成的调整?配置项看看?或者其他方向。

So, is there any tuning that can be done? Configuration items to look at? Or other direction.

我们的系统使用JSF和Spring构建表示层,后端是EJB,Spring和Hibernate都在WebSphere 6.1上运行。

Our system is build using JSF and Spring for the presentation layer, the back end is EJB, Spring and Hibernate all running on WebSphere 6.1.

推荐答案

JSF是一项非常有用的技术,但你可以自己解决这个问题。

JSF is a useful technology, but you can certainly hang yourself with it.

听起来好像是要么夸大视图状态的大小(通过在组件上设置大值),要么将组件的引用泄漏到其他会话状态(这会很糟糕)。另一个潜在的罪魁祸首是一个过大的视图(我已经看到人们可以轻松构建UI树,导致无处不在的数据表非常大的控制图)。我知道IBM提供了丰富的文本和电子表格控件 - 我无法评论它们对状态大小的影响。

It sounds like, either you're inflating the size of the view state (by setting large values on components) or you're leaking references to components into other session state (which would be bad). Another potential culprit would be an excessively large view (I've seen the ease with which people can build UI trees lead to very big control graphs with data tables everywhere). I know that IBM provides rich text and spreadsheet controls - I can't comment on what effect the use of these will have on state size.

低挂果实是检查为 faces-config.xml 中的会话范围配置的托管bean。

The low hanging fruit is to check the managed beans configured for session scope in faces-config.xml.

JSF在请求之间保存两件事:

JSF saves two things between requests:


  • 视图(页面上的所有控件)

  • 视图状态(控件的状态)

这些是分开的,因为某些控件(例如数据表的子项)可以具有多个状态(每行一个)。状态可以保存到表单上的隐藏字段(如果未加密,可能是一个很大的安全隐患)或会话中。为了容纳共享相同会话的多个浏览器窗口(以及在某些实现中,支持后退按钮),存储多个视图。

These are separated because some controls, such as children of a data table, can have multiple states (one for each row). State can be saved to either a hidden field on the form (which, if unencrypted, can be a big security hazard) or in the session. In order to accommodate multiple browser windows sharing the same session (and, in some implementations, back button support), multiple views are stored.


  • 应该有一个配置选项来设置应用程序在任何给定时间在给定用户的会话中保留的视图状态数。

  • 您可以通过提供来衡量视图状态的大小 StateManager ,用于衡量保存的视图/状态(使用带有StateManager的公共构造函数在faces-config.xml中配置StateManager - 请参阅 JSF spec PDF更多细节;状态是可序列化的,您可以通过将其转储到流来检查其大小。)

  • There should be a configuration option to set the number of view states the app will keep in the session for a given user at any given time.
  • You can measure the size of view state by providing a StateManager that measures the size of the saved view/state (configure a StateManager in faces-config.xml with a public constructor that takes a StateManager - see the JSF spec PDFs for more details; the state is serializable and you can check its size by dumping it to a stream).

大多数IDE构建的JSF应用程序都有支持bean。通过会话bean作用域可以保持比你想要的更长的状态,这会对会话造成压力。由于每页往往有一个支持bean,所以页面越多,问题就越大。检查 faces-config.xml 以查看这是否是潜在的问题来源。

Most IDE-built JSF apps have backing beans. It would be possible, via session bean scope to hold onto state longer than you want, placing a strain on the session. Since there tends to be one backing bean per page, the more pages you have, the bigger the problem will be. Check your faces-config.xml to see if this is a potential source of problems.

您可以做的其他事情是配置一个 web中的 HttpSessionAttributeListener .XML 。您可以获得堆栈跟踪帮助您确定应用中的问题区域。

Something else you could do would be to configure a HttpSessionAttributeListener in your web.xml. You can get a stack trace to help identify problem areas in your app.

这篇关于JSF调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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