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

public abstract Class SpringBeanAutowiringSupport

extends Object
Class Inheritance
Imports
jakarta.servlet.ServletContext, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor, org.springframework.util.Assert, .ClassUtils, org.springframework.web.context.ContextLoader, .WebApplicationContext

Convenient base class for self-autowiring classes that gets constructed within a Spring-based web application. Resolves @Autowired annotations in the endpoint class against beans in the current Spring root web application context (as determined by the current thread's context ClassLoader, which needs to be the web application's ClassLoader). Can alternatively be used as a delegate instead of as a base class.

A typical usage of this base class is a JAX-WS endpoint class: Such a Spring-based JAX-WS endpoint implementation will follow the standard JAX-WS contract for endpoint classes but will be 'thin' in that it delegates the actual work to one or more Spring-managed service beans - typically obtained using @Autowired. The lifecycle of such an endpoint instance will be managed by the JAX-WS runtime, hence the need for this base class to provide @Autowired processing based on the current Spring context.

Note

If there is an explicit way to access the ServletContext, prefer such a way over using this class. The WebApplicationContextUtils class allows for easy access to the Spring root web application context based on the ServletContext.

Author
Juergen Hoeller
Since
2.5.1
See Also
WebApplicationObjectSupport

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
public
SpringBeanAutowiringSupport()

This constructor performs injection on this instance, based on the current web application context.

Method Summary

Modifier and TypeMethod and Description
public static void
processInjectionBasedOnCurrentContext(Object
the target object to process
target
)

Process @Autowired injection for the given target object, based on the current web application context.

public static void
processInjectionBasedOnServletContext(Object
the target object to process
target
,
ServletContext
the ServletContext to find the Spring web application context in
servletContext
)

Process @Autowired injection for the given target object, based on the current root web application context as stored in the ServletContext.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private static final Log logger

Constructor Detail

SpringBeanAutowiringSupportback to summary
public SpringBeanAutowiringSupport()

This constructor performs injection on this instance, based on the current web application context.

Intended for use as a base class.

See Also
processInjectionBasedOnCurrentContext

Method Detail

processInjectionBasedOnCurrentContextback to summary
public static void processInjectionBasedOnCurrentContext(Object target)

Process @Autowired injection for the given target object, based on the current web application context.

Intended for use as a delegate.

Parameters
target:Object

the target object to process

See Also
org.springframework.web.context.ContextLoader#getCurrentWebApplicationContext()
processInjectionBasedOnServletContextback to summary
public static void processInjectionBasedOnServletContext(Object target, ServletContext servletContext)

Process @Autowired injection for the given target object, based on the current root web application context as stored in the ServletContext.

Intended for use as a delegate.

Parameters
target:Object

the target object to process

servletContext:ServletContext

the ServletContext to find the Spring web application context in

See Also
WebApplicationContextUtils#getWebApplicationContext(jakarta.servlet.ServletContext)