站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

WebApplicationObjectSupport (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.web.context.support
Class WebApplicationObjectSupport

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
All Implemented Interfaces:
ApplicationContextAware
Direct Known Subclasses:
AbstractCachingViewResolver, AbstractHandlerMapping, AbstractView, BeanNameViewResolver, TilesConfigurer, WebContentGenerator

public abstract class WebApplicationObjectSupport
extends ApplicationObjectSupport

Convenient superclass for application objects running in a WebApplicationContext. Provides getWebApplicationContext, getServletContext, and getTempDir methods.

Since:
28.08.2003
Author:
Juergen Hoeller

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  boolean isContextRequired()
          Overrides the base class behavior to enforce running in an ApplicationContext.
 
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

WebApplicationObjectSupport

public WebApplicationObjectSupport()
Method Detail

isContextRequired

protected boolean isContextRequired()
Overrides the base class behavior to enforce running in an ApplicationContext. All accessors will throw IllegalStateException if not running in a context.

Overrides:
isContextRequired in class ApplicationObjectSupport
See Also:
ApplicationObjectSupport.getApplicationContext(), ApplicationObjectSupport.getMessageSourceAccessor(), getWebApplicationContext(), getServletContext(), getTempDir()

getWebApplicationContext

protected final WebApplicationContext getWebApplicationContext()
                                                        throws IllegalStateException
Return the current application context as WebApplicationContext.

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.

Throws:
IllegalStateException - if not running in a WebApplicationContext
See Also:
ApplicationObjectSupport.getApplicationContext()

getServletContext

protected final ServletContext getServletContext()
                                          throws IllegalStateException
Return the current ServletContext.

Throws:
IllegalStateException - if not running within a ServletContext

getTempDir

protected final File getTempDir()
                         throws IllegalStateException
Return 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:
WebUtils.getTempDir(javax.servlet.ServletContext)


Copyright (c) 2002-2007 The Spring Framework Project.