Accessing FacesContext in Util jar from multiple portlets

你离开我真会死。 提交于 2019-12-08 06:23:56

问题


We have several JSF portlets running in a websphere portal environment. A developer wants to create a Utility jar which would live in the shared library, so all portlets could access it. In this jar he wants a faces utility class which would have a static method; this method would access the current FacesContext instance and return that context's session map.

We have been having some discussion over whether this is a wise approach, and how we know for sure that the correct context instance will be returned to each portlet instance. Any experience doing this, for better or for worse?


回答1:


FacesContext.getCurrentInstance() encapsulates the artefacts associated with a request. The context is thread-local - it is set up at the start of a request and disposed at the end by the portlet acting as the controller. So, so long as you can guarantee that the code is invoked as part of the request, it should be OK; problems will occur if the invocation escapes the request thread.



来源:https://stackoverflow.com/questions/1883893/accessing-facescontext-in-util-jar-from-multiple-portlets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!