Class BeanFactoryAspectInstanceFactory
java.lang.Object
org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory
- All Implemented Interfaces:
Serializable
,MetadataAwareAspectInstanceFactory
,AspectInstanceFactory
,org.springframework.core.Ordered
- Direct Known Subclasses:
PrototypeAspectInstanceFactory
public class BeanFactoryAspectInstanceFactory
extends Object
implements MetadataAwareAspectInstanceFactory, Serializable
AspectInstanceFactory
implementation
backed by a Spring BeanFactory
.
Note that this may instantiate multiple times if using a prototype,
which probably won't give the semantics you expect.
Use a LazySingletonAspectInstanceFactoryDecorator
to wrap this to ensure only one new aspect comes back.
- Since:
- 2.0
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionBeanFactoryAspectInstanceFactory
(org.springframework.beans.factory.BeanFactory beanFactory, String name) Create a BeanFactoryAspectInstanceFactory.BeanFactoryAspectInstanceFactory
(org.springframework.beans.factory.BeanFactory beanFactory, String name, Class<?> type) Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should introspect to create AJType metadata. -
Method Summary
Modifier and TypeMethodDescriptionExpose the aspect class loader that this factory uses.Return the best possible creation mutex for this factory.Create an instance of this factory's aspect.Return the AspectJ AspectMetadata for this factory's aspect.int
getOrder()
Determine the order for this factory's target aspect, either an instance-specific order expressed through implementing theOrdered
interface (only checked for singleton beans), or an order expressed through theOrder
annotation at the class level.toString()
-
Constructor Details
-
BeanFactoryAspectInstanceFactory
public BeanFactoryAspectInstanceFactory(org.springframework.beans.factory.BeanFactory beanFactory, String name) Create a BeanFactoryAspectInstanceFactory. AspectJ will be called to introspect to create AJType metadata using the type returned for the given bean name from the BeanFactory.- Parameters:
beanFactory
- the BeanFactory to obtain instance(s) fromname
- the name of the bean
-
BeanFactoryAspectInstanceFactory
public BeanFactoryAspectInstanceFactory(org.springframework.beans.factory.BeanFactory beanFactory, String name, @Nullable Class<?> type) Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should introspect to create AJType metadata. Use if the BeanFactory may consider the type to be a subclass (as when using CGLIB), and the information should relate to a superclass.- Parameters:
beanFactory
- the BeanFactory to obtain instance(s) fromname
- the name of the beantype
- the type that should be introspected by AspectJ (null
indicates resolution throughBeanFactory.getType(java.lang.String)
via the bean name)
-
-
Method Details
-
getAspectInstance
Description copied from interface:AspectInstanceFactory
Create an instance of this factory's aspect.- Specified by:
getAspectInstance
in interfaceAspectInstanceFactory
- Returns:
- the aspect instance (never
null
)
-
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()
-
getAspectMetadata
Description copied from interface:MetadataAwareAspectInstanceFactory
Return the AspectJ AspectMetadata for this factory's aspect.- Specified by:
getAspectMetadata
in interfaceMetadataAwareAspectInstanceFactory
- Returns:
- the aspect metadata
-
getAspectCreationMutex
Description copied from interface:MetadataAwareAspectInstanceFactory
Return the best possible creation mutex for this factory.- Specified by:
getAspectCreationMutex
in interfaceMetadataAwareAspectInstanceFactory
- Returns:
- the mutex object (may be
null
for no mutex to use)
-
getOrder
public int getOrder()Determine the order for this factory's target aspect, either an instance-specific order expressed through implementing theOrdered
interface (only checked for singleton beans), or an order expressed through theOrder
annotation at the class level.- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- See Also:
-
Ordered
Order
-
toString
-