|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.context.support.WebApplicationContextUtils
public abstract class WebApplicationContextUtils
Convenience methods for retrieving the root
WebApplicationContext
for a given
ServletContext
. This is e.g. useful for accessing a Spring
context from within custom web views or Struts actions.
Note that there are more convenient ways of accessing the root context for many web frameworks, either part of Spring or available as external library. This helper class is just the most generic way to access the root context.
ContextLoader
,
FrameworkServlet
,
DispatcherServlet
,
FacesContextUtils
,
SpringBeanVariableResolver
,
SpringBeanFacesELResolver
Nested Class Summary | |
---|---|
private static class |
WebApplicationContextUtils.FacesDependencyRegistrar
Inner class to avoid hard-coded JSF dependency. |
private static class |
WebApplicationContextUtils.RequestObjectFactory
Factory that exposes the current request object on demand. |
private static class |
WebApplicationContextUtils.SessionObjectFactory
Factory that exposes the current session object on demand. |
private static class |
WebApplicationContextUtils.WebRequestObjectFactory
Factory that exposes the current WebRequest object on demand. |
Field Summary | |
---|---|
private static boolean |
jsfPresent
|
Constructor Summary | |
---|---|
WebApplicationContextUtils()
|
Method Summary | |
---|---|
private static ServletRequestAttributes |
currentRequestAttributes()
Return the current RequestAttributes instance as ServletRequestAttributes. |
static WebApplicationContext |
getRequiredWebApplicationContext(ServletContext sc)
Find the root WebApplicationContext for this web application, which is typically loaded via ContextLoaderListener . |
static WebApplicationContext |
getWebApplicationContext(ServletContext sc)
Find the root WebApplicationContext for this web application, which is typically loaded via ContextLoaderListener . |
static WebApplicationContext |
getWebApplicationContext(ServletContext sc,
java.lang.String attrName)
Find a custom WebApplicationContext for this web application. |
static void |
registerEnvironmentBeans(ConfigurableListableBeanFactory bf,
ServletContext sc)
Register web-specific environment beans ("contextParameters", "contextAttributes") with the given BeanFactory, as used by the WebApplicationContext. |
static void |
registerEnvironmentBeans(ConfigurableListableBeanFactory bf,
ServletContext sc,
ServletConfig config)
Register web-specific environment beans ("contextParameters", "contextAttributes") with the given BeanFactory, as used by the WebApplicationContext. |
static void |
registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory)
Register web-specific scopes ("request", "session", "globalSession") with the given BeanFactory, as used by the WebApplicationContext. |
static void |
registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory,
ServletContext sc)
Register web-specific scopes ("request", "session", "globalSession", "application") with the given BeanFactory, as used by the WebApplicationContext. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean jsfPresent
Constructor Detail |
---|
public WebApplicationContextUtils()
Method Detail |
---|
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws java.lang.IllegalStateException
ContextLoaderListener
.
Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
sc
- ServletContext to find the web application context for
java.lang.IllegalStateException
- if the root WebApplicationContext could not be foundWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
public static WebApplicationContext getWebApplicationContext(ServletContext sc)
ContextLoaderListener
.
Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
sc
- ServletContext to find the web application context for
null
if noneWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
public static WebApplicationContext getWebApplicationContext(ServletContext sc, java.lang.String attrName)
sc
- ServletContext to find the web application context forattrName
- the name of the ServletContext attribute to look for
null
if nonepublic static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory)
beanFactory
- the BeanFactory to configurepublic static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContext sc)
beanFactory
- the BeanFactory to configuresc
- the ServletContext that we're running withinpublic static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContext sc)
bf
- the BeanFactory to configuresc
- the ServletContext that we're running withinpublic static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContext sc, ServletConfig config)
bf
- the BeanFactory to configuresc
- the ServletContext that we're running withinconfig
- the ServletConfig of the containing Portletprivate static ServletRequestAttributes currentRequestAttributes()
RequestContextHolder.currentRequestAttributes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |