类 SpringBeanAutowiringSupport
- java.lang.Object
- org.springframework.web.context.support.SpringBeanAutowiringSupport
public abstract class SpringBeanAutowiringSupport extends Object
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.- 从以下版本开始:
- 2.5.1
- 作者:
- Juergen Hoeller
- 另请参阅:
WebApplicationObjectSupport
构造器概要
构造器 构造器 说明 SpringBeanAutowiringSupport()
This constructor performs injection on this instance, based on the current web application context.
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
processInjectionBasedOnCurrentContext(Object target)
Process@Autowired
injection for the given target object, based on the current web application context.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.
构造器详细资料
SpringBeanAutowiringSupport
public SpringBeanAutowiringSupport()
This constructor performs injection on this instance, based on the current web application context.Intended for use as a base class.
方法详细资料
processInjectionBasedOnCurrentContext
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.
- 参数:
target
- the target object to process- 另请参阅:
ContextLoader.getCurrentWebApplicationContext()
processInjectionBasedOnServletContext
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.
- 参数:
target
- the target object to processservletContext
- the ServletContext to find the Spring web application context in- 另请参阅:
WebApplicationContextUtils.getWebApplicationContext(javax.servlet.ServletContext)