Top Description Fields Constructors Methods
org.springframework.web.context.support

public Class ServletContextAwareProcessor

extends Object
implements BeanPostProcessor
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.config.BeanPostProcessor
Imports
jakarta.servlet.ServletConfig, .ServletContext, org.springframework.beans.BeansException, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.lang.Nullable, org.springframework.web.context.ServletConfigAware, .ServletContextAware

org.springframework.beans.factory.config.BeanPostProcessor implementation that passes the ServletContext to beans that implement the ServletContextAware interface.

Web application contexts will automatically register this with their underlying bean factory. Applications do not use this directly.

Authors
Juergen Hoeller, Phillip Webb
Since
12.03.2004
See Also
org.springframework.web.context.ServletContextAware, org.springframework.web.context.support.XmlWebApplicationContext#postProcessBeanFactory

Field Summary

Modifier and TypeField and Description
private ServletConfig
private ServletContext

Constructor Summary

AccessConstructor and Description
protected
ServletContextAwareProcessor()

Create a new ServletContextAwareProcessor without an initial context or config.

public
ServletContextAwareProcessor(ServletContext servletContext)

Create a new ServletContextAwareProcessor for the given context.

public
ServletContextAwareProcessor(ServletConfig servletConfig)

Create a new ServletContextAwareProcessor for the given config.

public
ServletContextAwareProcessor(ServletContext servletContext, ServletConfig servletConfig)

Create a new ServletContextAwareProcessor for the given context and config.

Method Summary

Modifier and TypeMethod and Description
protected ServletConfig
getServletConfig()

Returns the ServletConfig to be injected or null.

protected ServletContext
getServletContext()

Returns the ServletContext to be injected or null.

public Object
postProcessAfterInitialization(Object
the new bean instance
bean
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method).

public Object
postProcessBeforeInitialization(Object
the new bean instance
bean
,
String
the name of the bean
beanName
)

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessBeforeInitialization.

Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

servletConfigback to summary
private ServletConfig servletConfig
Annotations
@Nullable
servletContextback to summary
private ServletContext servletContext
Annotations
@Nullable

Constructor Detail

ServletContextAwareProcessorback to summary
protected ServletContextAwareProcessor()

Create a new ServletContextAwareProcessor without an initial context or config. When this constructor is used the getServletContext() and/or getServletConfig() methods should be overridden.

ServletContextAwareProcessorback to summary
public ServletContextAwareProcessor(ServletContext servletContext)

Create a new ServletContextAwareProcessor for the given context.

ServletContextAwareProcessorback to summary
public ServletContextAwareProcessor(ServletConfig servletConfig)

Create a new ServletContextAwareProcessor for the given config.

ServletContextAwareProcessorback to summary
public ServletContextAwareProcessor(ServletContext servletContext, ServletConfig servletConfig)

Create a new ServletContextAwareProcessor for the given context and config.

Method Detail

getServletConfigback to summary
protected ServletConfig getServletConfig()

Returns the ServletConfig to be injected or null. This method can be overridden by subclasses when a context is obtained after the post-processor has been registered.

Annotations
@Nullable
getServletContextback to summary
protected ServletContext getServletContext()

Returns the ServletContext to be injected or null. This method can be overridden by subclasses when a context is obtained after the post-processor has been registered.

Annotations
@Nullable
postProcessAfterInitializationback to summary
public Object postProcessAfterInitialization(Object bean, String beanName)

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

Doc from org.springframework.beans.factory.config.BeanPostProcessor.postProcessAfterInitialization.

Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding bean instanceof FactoryBean checks.

This callback will also be invoked after a short-circuiting triggered by a InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation method, in contrast to all other BeanPostProcessor callbacks.

The default implementation returns the given bean as-is.

Parameters
bean:Object

the new bean instance

beanName:String

the name of the bean

Returns:Object

the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked

Annotations
@Override
postProcessBeforeInitializationback to summary
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException

Overrides default org.springframework.beans.factory.config.BeanPostProcessor.postProcessBeforeInitialization.

Doc from org.springframework.beans.factory.config.BeanPostProcessor.postProcessBeforeInitialization.

Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

The default implementation returns the given bean as-is.

Parameters
bean:Object

the new bean instance

beanName:String

the name of the bean

Returns:Object

the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked

Annotations
@Override
Exceptions
BeansException:
in case of errors