类 FacesContextUtils
- java.lang.Object
- org.springframework.web.jsf.FacesContextUtils
public abstract class FacesContextUtils extends Object
Convenience methods to retrieve Spring's rootWebApplicationContextfor a given JSFFacesContext. This is useful for accessing a Spring application context from custom JSF-based code.Analogous to Spring's WebApplicationContextUtils for the ServletContext.
- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
ContextLoader,WebApplicationContextUtils
构造器概要
构造器 构造器 说明 FacesContextUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static WebApplicationContextgetRequiredWebApplicationContext(FacesContext fc)Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.static ObjectgetSessionMutex(FacesContext fc)Return the best available mutex for the given session: that is, an object to synchronize on for the given session.static WebApplicationContextgetWebApplicationContext(FacesContext fc)Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.
构造器详细资料
FacesContextUtils
public FacesContextUtils()
方法详细资料
getWebApplicationContext
public static WebApplicationContext getWebApplicationContext(FacesContext fc)
Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- 参数:
fc- the FacesContext to find the web application context for- 返回:
- the root WebApplicationContext for this web app, or
nullif none - 另请参阅:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) throws IllegalStateException
Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- 参数:
fc- the FacesContext to find the web application context for- 返回:
- the root WebApplicationContext for this web app
- 抛出:
IllegalStateException- if the root WebApplicationContext could not be found- 另请参阅:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
getSessionMutex
public static Object getSessionMutex(FacesContext fc)
Return the best available mutex for the given session: that is, an object to synchronize on for the given session.Returns the session mutex attribute if available; usually, this means that the HttpSessionMutexListener needs to be defined in
web.xml. Falls back to the Session reference itself if no mutex attribute found.The session mutex is guaranteed to be the same object during the entire lifetime of the session, available under the key defined by the
SESSION_MUTEX_ATTRIBUTEconstant. It serves as a safe reference to synchronize on for locking on the current session.In many cases, the Session reference itself is a safe mutex as well, since it will always be the same object reference for the same active logical session. However, this is not guaranteed across different servlet containers; the only 100% safe way is a session mutex.
- 参数:
fc- the FacesContext to find the session mutex for- 返回:
- the mutex object (never
null) - 另请参阅:
WebUtils.SESSION_MUTEX_ATTRIBUTE,HttpSessionMutexListener