The Spring Framework

org.springframework.aop.aspectj.annotation
Class BeanFactoryAspectInstanceFactory

java.lang.Object
  extended by org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory
All Implemented Interfaces:
MetadataAwareAspectInstanceFactory, AspectInstanceFactory
Direct Known Subclasses:
PrototypeAspectInstanceFactory

public class BeanFactoryAspectInstanceFactory
extends Object
implements MetadataAwareAspectInstanceFactory

AspectInstanceFactory backed by Spring IoC bean.

Note that this may instantiate multiple times if using a prototype, which probably won't give the semantics you expect. Use a LazySingletonMetadataAwareAspectInstanceFactoryDecorator to wrap this to ensure only one new aspect comes back.

Since:
2.0
Author:
Rod Johnson
See Also:
LazySingletonMetadataAwareAspectInstanceFactoryDecorator

Constructor Summary
BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name)
          Create a BeanFactoryAspectInstance factory.
BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name, Class type)
          Create a BeanFactoryAspectInstance factory, providing a type that AspectJ should introspect to create AJType metadata.
 
Method Summary
 Object getAspectInstance()
          Create an instance of this factory's aspect.
 AspectMetadata getAspectMetadata()
           
 int getInstantiationCount()
          Return the number of instantiations from this factory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanFactoryAspectInstanceFactory

public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory,
                                        String name)
Create a BeanFactoryAspectInstance factory. AspectJ will be called to introspect to create AJType metadata using the type returned for the given bean name from the BeanFactory.

Parameters:
beanFactory - BeanFactory to obtain instance(s) from
name - name of the bean

BeanFactoryAspectInstanceFactory

public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory,
                                        String name,
                                        Class type)
Create a BeanFactoryAspectInstance factory, 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 - BeanFactory to obtain instance(s) from
name - name of the bean
type - type that should be introspected by AspectJ.
Method Detail

getAspectInstance

public Object getAspectInstance()
Description copied from interface: AspectInstanceFactory
Create an instance of this factory's aspect.

Specified by:
getAspectInstance in interface AspectInstanceFactory

getAspectMetadata

public AspectMetadata getAspectMetadata()
Specified by:
getAspectMetadata in interface MetadataAwareAspectInstanceFactory

getInstantiationCount

public int getInstantiationCount()
Description copied from interface: AspectInstanceFactory
Return the number of instantiations from this factory.

Specified by:
getInstantiationCount in interface AspectInstanceFactory
Returns:
the number of aspect instances created

toString

public String toString()
Overrides:
toString in class Object

The Spring Framework

Copyright © 2002-2006 The Spring Framework.