Package org.springframework.aop.config
Class SimpleBeanFactoryAwareAspectInstanceFactory
- java.lang.Object
- org.springframework.aop.config.SimpleBeanFactoryAwareAspectInstanceFactory
- All Implemented Interfaces:
AspectInstanceFactory
,Aware
,BeanFactoryAware
,Ordered
public class SimpleBeanFactoryAwareAspectInstanceFactory extends Object implements AspectInstanceFactory, BeanFactoryAware
Implementation ofAspectInstanceFactory
that locates the aspect from theBeanFactory
using a configured bean name.- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor Summary
Constructors Constructor Description SimpleBeanFactoryAwareAspectInstanceFactory()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassLoader
getAspectClassLoader()
Expose the aspect class loader that this factory uses.Object
getAspectInstance()
Look up the aspect bean from theBeanFactory
and returns it.int
getOrder()
Get the order value of this object.void
setAspectBeanName(String aspectBeanName)
Set the name of the aspect bean.void
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
Constructor Detail
SimpleBeanFactoryAwareAspectInstanceFactory
public SimpleBeanFactoryAwareAspectInstanceFactory()
Method Detail
setAspectBeanName
public void setAspectBeanName(String aspectBeanName)
Set the name of the aspect bean. This is the bean that is returned when callinggetAspectInstance()
.
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
Description copied from interface:BeanFactoryAware
Callback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
BeanInitializationException
getAspectInstance
public Object getAspectInstance()
Look up the aspect bean from theBeanFactory
and returns it.- Specified by:
getAspectInstance
in interfaceAspectInstanceFactory
- Returns:
- the aspect instance (never
null
) - See Also:
setAspectBeanName(java.lang.String)
getAspectClassLoader
@Nullable public ClassLoader getAspectClassLoader()
Description copied from interface:AspectInstanceFactory
Expose the aspect class loader that this factory uses.- Specified by:
getAspectClassLoader
in interfaceAspectInstanceFactory
- Returns:
- the aspect class loader (or
null
for the bootstrap loader) - See Also:
ClassUtils.getDefaultClassLoader()
getOrder
public int getOrder()
Description copied from interface:Ordered
Get the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrder
in interfaceOrdered
- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE