|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport
public abstract class WebApplicationObjectSupport
Convenient superclass for application objects running in a WebApplicationContext.
Provides getWebApplicationContext()
, getServletContext()
,
and getTempDir()
methods.
SpringBeanAutowiringSupport
Field Summary |
---|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
Constructor Summary | |
---|---|
WebApplicationObjectSupport()
|
Method Summary | |
---|---|
protected ServletContext |
getServletContext()
Return the current ServletContext. |
protected File |
getTempDir()
Return the temporary directory for the current web application, as provided by the servlet container. |
protected WebApplicationContext |
getWebApplicationContext()
Return the current application context as WebApplicationContext. |
protected void |
initApplicationContext(ApplicationContext context)
Calls initServletContext(javax.servlet.ServletContext) if the
given ApplicationContext is a WebApplicationContext . |
protected void |
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based on the ServletContext that this application object runs in. |
protected boolean |
isContextRequired()
Overrides the base class behavior to enforce running in an ApplicationContext. |
void |
setServletContext(ServletContext servletContext)
Set the ServletContext that this object runs in. |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WebApplicationObjectSupport()
Method Detail |
---|
public final void setServletContext(ServletContext servletContext)
ServletContextAware
Invoked after population of normal bean properties but before an init
callback like InitializingBean's afterPropertiesSet
or a
custom init-method. Invoked after ApplicationContextAware's
setApplicationContext
.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectInitializingBean.afterPropertiesSet()
,
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
protected boolean isContextRequired()
isContextRequired
in class ApplicationObjectSupport
ApplicationObjectSupport.getApplicationContext()
,
ApplicationObjectSupport.getMessageSourceAccessor()
,
getWebApplicationContext()
,
getServletContext()
,
getTempDir()
protected void initApplicationContext(ApplicationContext context)
initServletContext(javax.servlet.ServletContext)
if the
given ApplicationContext is a WebApplicationContext
.
initApplicationContext
in class ApplicationObjectSupport
context
- the containing ApplicationContextApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)
protected void initServletContext(ServletContext servletContext)
The default implementation is empty. Called by
initApplicationContext(org.springframework.context.ApplicationContext)
as well as setServletContext(javax.servlet.ServletContext)
.
servletContext
- the ServletContext that this application object runs in
(never null
)protected final WebApplicationContext getWebApplicationContext() throws IllegalStateException
NOTE: Only use this if you actually need to access
WebApplicationContext-specific functionality. Preferably use
getApplicationContext()
or getServletContext()
else, to be able to run in non-WebApplicationContext environments as well.
IllegalStateException
- if not running in a WebApplicationContextApplicationObjectSupport.getApplicationContext()
protected final ServletContext getServletContext() throws IllegalStateException
IllegalStateException
- if not running within a ServletContextprotected final File getTempDir() throws IllegalStateException
IllegalStateException
- if not running within a ServletContextWebUtils.getTempDir(javax.servlet.ServletContext)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |