类 WebApplicationObjectSupport

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.servlet.WebApplicationObjectSupport
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.context.ApplicationContextAware, ServletContextAware

public class WebApplicationObjectSupport extends cn.taketoday.context.support.ApplicationObjectSupport implements ServletContextAware
Convenient superclass for application objects running in a 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.

从以下版本开始:
2019-12-27 09:36
作者:
Juergen Hoeller, TODAY
  • 字段详细资料

  • 构造器详细资料

    • WebApplicationObjectSupport

      public WebApplicationObjectSupport()
  • 方法详细资料

    • setServletContext

      public final void setServletContext(ServletContext servletContext)
      从接口复制的说明: ServletContextAware
      Set the ServletContext that this object runs in.

      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 在接口中 ServletContextAware
      参数:
      servletContext - the ServletContext object to be used by this object
      另请参阅:
      • InitializingBean.afterPropertiesSet()
      • ApplicationContextAware.setApplicationContext(cn.taketoday.context.ApplicationContext)
    • 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.
      覆盖:
      isContextRequired 在类中 cn.taketoday.context.support.ApplicationObjectSupport
      另请参阅:
    • initApplicationContext

      protected void initApplicationContext(cn.taketoday.context.ApplicationContext context)
      覆盖:
      initApplicationContext 在类中 cn.taketoday.context.support.ApplicationObjectSupport
    • initServletContext

      protected void initServletContext(ServletContext servletContext)
      Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.

      The default implementation is empty. Called by initApplicationContext(ApplicationContext) as well as setServletContext(jakarta.servlet.ServletContext).

      参数:
      servletContext - the ServletContext that this application object runs in (never null)
    • getWebApplicationContext

      @Nullable 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.

      抛出:
      IllegalStateException - if not running in a WebApplicationContext
      另请参阅:
      • ApplicationObjectSupport.getApplicationContext()
    • getServletContext

      @Nullable protected final ServletContext getServletContext() throws IllegalStateException
      Return the current ServletContext.
      抛出:
      IllegalStateException - if not running within a required ServletContext
      另请参阅:
    • getTempDir

      protected final File getTempDir() throws IllegalStateException
      Return the temporary directory for the current web application, as provided by the servlet container.
      返回:
      the File representing the temporary directory
      抛出:
      IllegalStateException - if not running within a ServletContext
      另请参阅: