类 SpringBeanAutowiringInterceptor
- java.lang.Object
- org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor
public class SpringBeanAutowiringInterceptor extends Object
EJB3-compliant interceptor class that injects Spring beans into fields and methods which are annotated with@Autowired
. Performs injection after construction as well as after activation of a passivated bean.To be applied through an
@Interceptors
annotation in the EJB Session Bean or Message-Driven Bean class, or through aninterceptor-binding
XML element in the EJB deployment descriptor.Delegates to Spring's
AutowiredAnnotationBeanPostProcessor
underneath, allowing for customization of its specific settings through overriding theconfigureBeanPostProcessor(org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor, java.lang.Object)
template method.The actual BeanFactory to obtain Spring beans from is determined by the
getBeanFactory(java.lang.Object)
template method. The default implementation obtains the SpringContextSingletonBeanFactoryLocator
, initialized from the default resource location classpath*:beanRefContext.xml, and obtains the single ApplicationContext defined there.NOTE: If you have more than one shared ApplicationContext definition available in your EJB class loader, you need to override the
getBeanFactoryLocatorKey(java.lang.Object)
method and provide a specific locator key for each autowired EJB. Alternatively, override thegetBeanFactory(java.lang.Object)
template method and obtain the target factory explicitly.WARNING: Do not define the same bean as Spring-managed bean and as EJB3 session bean in the same deployment unit. In particular, be careful when using the
<context:component-scan>
feature in combination with the deployment of Spring-based EJB3 session beans: Make sure that the EJB3 session beans are not autodetected as Spring-managed beans as well, using appropriate package restrictions.- 从以下版本开始:
- 2.5.1
- 作者:
- Juergen Hoeller
- 另请参阅:
Autowired
,AutowiredAnnotationBeanPostProcessor
,ContextSingletonBeanFactoryLocator
,getBeanFactoryLocatorKey(java.lang.Object)
构造器概要
构造器 构造器 说明 SpringBeanAutowiringInterceptor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
autowireBean(InvocationContext invocationContext)
Autowire the target bean after construction as well as after passivation.protected void
configureBeanPostProcessor(AutowiredAnnotationBeanPostProcessor processor, Object target)
Template method for configuring theAutowiredAnnotationBeanPostProcessor
used for autowiring.protected void
doAutowireBean(Object target)
Actually autowire the target bean after construction/passivation.protected void
doReleaseBean(Object target)
Actually release the BeanFactoryReference for the given target bean.protected BeanFactory
getBeanFactory(Object target)
Determine the BeanFactory for autowiring the given target bean.protected BeanFactoryLocator
getBeanFactoryLocator(Object target)
Determine the BeanFactoryLocator to obtain the BeanFactoryReference from.protected String
getBeanFactoryLocatorKey(Object target)
Determine the BeanFactoryLocator key to use.protected BeanFactoryReference
getBeanFactoryReference(Object target)
Determine the BeanFactoryReference for the given target bean.void
releaseBean(InvocationContext invocationContext)
Release the factory which has been used for autowiring the target bean.
构造器详细资料
SpringBeanAutowiringInterceptor
public SpringBeanAutowiringInterceptor()
方法详细资料
autowireBean
public void autowireBean(InvocationContext invocationContext)
Autowire the target bean after construction as well as after passivation.- 参数:
invocationContext
- the EJB3 invocation context
doAutowireBean
protected void doAutowireBean(Object target)
Actually autowire the target bean after construction/passivation.- 参数:
target
- the target bean to autowire
configureBeanPostProcessor
protected void configureBeanPostProcessor(AutowiredAnnotationBeanPostProcessor processor, Object target)
Template method for configuring theAutowiredAnnotationBeanPostProcessor
used for autowiring.- 参数:
processor
- the AutowiredAnnotationBeanPostProcessor to configuretarget
- the target bean to autowire with this processor
getBeanFactory
protected BeanFactory getBeanFactory(Object target)
Determine the BeanFactory for autowiring the given target bean.- 参数:
target
- the target bean to autowire- 返回:
- the BeanFactory to use (never
null
) - 另请参阅:
getBeanFactoryReference(java.lang.Object)
getBeanFactoryReference
protected BeanFactoryReference getBeanFactoryReference(Object target)
Determine the BeanFactoryReference for the given target bean.The default implementation delegates to
getBeanFactoryLocator(java.lang.Object)
andgetBeanFactoryLocatorKey(java.lang.Object)
.- 参数:
target
- the target bean to autowire- 返回:
- the BeanFactoryReference to use (never
null
) - 另请参阅:
getBeanFactoryLocator(java.lang.Object)
,getBeanFactoryLocatorKey(java.lang.Object)
,BeanFactoryLocator.useBeanFactory(String)
getBeanFactoryLocator
protected BeanFactoryLocator getBeanFactoryLocator(Object target)
Determine the BeanFactoryLocator to obtain the BeanFactoryReference from.The default implementation exposes Spring's default
ContextSingletonBeanFactoryLocator
.- 参数:
target
- the target bean to autowire- 返回:
- the BeanFactoryLocator to use (never
null
) - 另请参阅:
ContextSingletonBeanFactoryLocator.getInstance()
getBeanFactoryLocatorKey
protected String getBeanFactoryLocatorKey(Object target)
Determine the BeanFactoryLocator key to use. This typically indicates the bean name of the ApplicationContext definition in classpath*:beanRefContext.xml resource files.The default is
null
, indicating the single ApplicationContext defined in the locator. This must be overridden if more than one shared ApplicationContext definition is available.- 参数:
target
- the target bean to autowire- 返回:
- the BeanFactoryLocator key to use (or
null
for referring to the single ApplicationContext defined in the locator)
releaseBean
public void releaseBean(InvocationContext invocationContext)
Release the factory which has been used for autowiring the target bean.- 参数:
invocationContext
- the EJB3 invocation context
doReleaseBean
protected void doReleaseBean(Object target)
Actually release the BeanFactoryReference for the given target bean.- 参数:
target
- the target bean to release