Class WebApplicationObjectSupport
- All Implemented Interfaces:
- Aware,- ApplicationContextAware,- ServletContextAware
- Direct Known Subclasses:
- AbstractCachingViewResolver,- AbstractHandlerMapping,- AbstractView,- BeanNameViewResolver,- ContentNegotiatingViewResolver,- ServerEndpointExporter,- WebContentGenerator
WebApplicationContext.
 Provides getWebApplicationContext(), getServletContext(), and
 getTempDir() accessors.
 Note: It is generally recommended to use individual callback interfaces for the actual
 callbacks needed. This broad base class is primarily intended for use within the framework,
 in case of ServletContext access etc typically being needed.
- Since:
- 28.08.2003
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class org.springframework.context.support.ApplicationObjectSupportlogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final ServletContextReturn the current ServletContext.protected final FileReturn the temporary directory for the current web application, as provided by the servlet container.protected final WebApplicationContextReturn the current application context as WebApplicationContext.protected voidinitApplicationContext(ApplicationContext context) CallsinitServletContext(jakarta.servlet.ServletContext)if the given ApplicationContext is aWebApplicationContext.protected voidinitServletContext(ServletContext servletContext) Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.protected booleanOverrides the base class behavior to enforce running in an ApplicationContext.final voidsetServletContext(ServletContext servletContext) Set theServletContextthat this object runs in.Methods inherited from class org.springframework.context.support.ApplicationObjectSupportgetApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
- 
Constructor Details- 
WebApplicationObjectSupportpublic WebApplicationObjectSupport()
 
- 
- 
Method Details- 
setServletContextDescription copied from interface:ServletContextAwareSet theServletContextthat this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSetor a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext.- Specified by:
- setServletContextin interface- ServletContextAware
- Parameters:
- servletContext- the ServletContext object to be used by this object
- See Also:
 
- 
isContextRequiredprotected boolean isContextRequired()Overrides the base class behavior to enforce running in an ApplicationContext. All accessors will throw IllegalStateException if not running in a context.
- 
initApplicationContextCallsinitServletContext(jakarta.servlet.ServletContext)if the given ApplicationContext is aWebApplicationContext.- Overrides:
- initApplicationContextin class- ApplicationObjectSupport
- Parameters:
- context- the containing ApplicationContext
- See Also:
 
- 
initServletContextSubclasses may override this for custom initialization based on the ServletContext that this application object runs in.The default implementation is empty. Called by initApplicationContext(org.springframework.context.ApplicationContext)as well assetServletContext(jakarta.servlet.ServletContext).- Parameters:
- servletContext- the ServletContext that this application object runs in (never- null)
 
- 
getWebApplicationContext@Nullable protected final WebApplicationContext getWebApplicationContext() throws IllegalStateExceptionReturn the current application context as WebApplicationContext.NOTE: Only use this if you actually need to access WebApplicationContext-specific functionality. Preferably use getApplicationContext()orgetServletContext()else, to be able to run in non-WebApplicationContext environments as well.- Throws:
- IllegalStateException- if not running in a WebApplicationContext
- See Also:
 
- 
getServletContextReturn the current ServletContext.- Throws:
- IllegalStateException- if not running within a required ServletContext
- See Also:
 
- 
getTempDirReturn the temporary directory for the current web application, as provided by the servlet container.- Returns:
- the File representing the temporary directory
- Throws:
- IllegalStateException- if not running within a ServletContext
- See Also:
 
 
-