org.springframework.web.jsf
Class FacesContextUtils

public class FacesContextUtils
Convenience methods to retrieve the root WebApplicationContext for a given FacesContext. This is e.g. useful for accessing a Spring context from custom JSF code.

Analogous to Spring's WebApplicationContextUtils for the ServletContext.

Since1.1
VersionNot specified.
AuthorJuergen Hoeller
Wiki javadoc Use textile entry format.
Add your comments here.
Constructor Summary
FacesContextUtils()
No description provided.
Method Summary
static WebApplicationContext getRequiredWebApplicationContext( FacesContext fc )
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.
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.
static WebApplicationContext getWebApplicationContext( FacesContext fc )
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.
FacesContextUtils
public FacesContextUtils ( )
No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext ( FacesContext fc )
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters
TypeNameDescription
FacesContext fc the FacesContext to find the web application context for
Exceptions
IllegalStateException if the root WebApplicationContext could not be found
Wiki javadoc Use textile entry format.
Add your comments here.
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_ATTRIBUTE constant. 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.

Parameters
TypeNameDescription
FacesContext fc the FacesContext to find the session mutex for
Wiki javadoc Use textile entry format.
Add your comments here.
getWebApplicationContext
public static WebApplicationContext getWebApplicationContext ( FacesContext fc )
Find the root WebApplicationContext for this web app, which is typically loaded via ContextLoaderListener or ContextLoaderServlet.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters
TypeNameDescription
FacesContext fc the FacesContext to find the web application context for
Wiki javadoc Use textile entry format.
Add your comments here.