org.springframework.aop.aspectj.annotation
Class AbstractAspectJAdvisorFactory

java.lang.Object
  extended by org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory
All Implemented Interfaces:
AspectJAdvisorFactory
Direct Known Subclasses:
ReflectiveAspectJAdvisorFactory

public abstract class AbstractAspectJAdvisorFactory
extends Object
implements AspectJAdvisorFactory

Abstract base class for factories that can create Spring AOP Advisors given AspectJ classes from classes honoring the AspectJ 5 annotation syntax.

This class handles annotation parsing and validation functionality. It does not actually generate Spring AOP Advisors, which is deferred to subclasses.

Since:
2.0
Author:
Rod Johnson, Adrian Colyer, Juergen Hoeller

Nested Class Summary
protected static class AbstractAspectJAdvisorFactory.AspectJAnnotation<A extends Annotation>
          Class modelling an AspectJ annotation, exposing its type enumeration and pointcut String.
protected static class AbstractAspectJAdvisorFactory.AspectJAnnotationType
           
 
Field Summary
protected static ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER
           
protected  Log logger
          Logger available to subclasses
protected  ParameterNameDiscoverer parameterNameDiscoverer
           
 
Constructor Summary
protected AbstractAspectJAdvisorFactory()
           
 
Method Summary
protected  AspectJExpressionPointcut createPointcutExpression(Method annotatedMethod, Class declarationScope, String[] pointcutParameterNames)
          The pointcut and advice annotations both have an "argNames" member which contains a comma-separated list of the argument names.
protected static AbstractAspectJAdvisorFactory.AspectJAnnotation findAspectJAnnotationOnMethod(Method method)
          Find and return the first AspectJ annotation on the given method (there should only be one anyway...)
 boolean isAspect(Class<?> clazz)
          We consider something to be an AspectJ aspect suitable for use by the Spring AOP system if it has the @Aspect annotation, and was not compiled by ajc.
 void validate(Class<?> aspectClass)
          Is the given class a valid AspectJ aspect class?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory
getAdvice, getAdvisor, getAdvisors
 

Field Detail

ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER

protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER

logger

protected final Log logger
Logger available to subclasses


parameterNameDiscoverer

protected final ParameterNameDiscoverer parameterNameDiscoverer
Constructor Detail

AbstractAspectJAdvisorFactory

protected AbstractAspectJAdvisorFactory()
Method Detail

findAspectJAnnotationOnMethod

protected static AbstractAspectJAdvisorFactory.AspectJAnnotation findAspectJAnnotationOnMethod(Method method)
Find and return the first AspectJ annotation on the given method (there should only be one anyway...)


isAspect

public boolean isAspect(Class<?> clazz)
We consider something to be an AspectJ aspect suitable for use by the Spring AOP system if it has the @Aspect annotation, and was not compiled by ajc. The reason for this latter test is that aspects written in the code-style (AspectJ language) also have the annotation present when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.

Specified by:
isAspect in interface AspectJAdvisorFactory
Parameters:
clazz - the supposed annotation-style AspectJ class
Returns:
whether or not this class is recognized by AspectJ as an aspect class

validate

public void validate(Class<?> aspectClass)
              throws AopConfigException
Description copied from interface: AspectJAdvisorFactory
Is the given class a valid AspectJ aspect class?

Specified by:
validate in interface AspectJAdvisorFactory
Parameters:
aspectClass - the supposed AspectJ annotation-style class to validate
Throws:
AopConfigException - if the class is an invalid aspect (which can never be legal)
NotAnAtAspectException - if the class is not an aspect at all (which may or may not be legal, depending on the context)

createPointcutExpression

protected AspectJExpressionPointcut createPointcutExpression(Method annotatedMethod,
                                                             Class declarationScope,
                                                             String[] pointcutParameterNames)
The pointcut and advice annotations both have an "argNames" member which contains a comma-separated list of the argument names. We use this (if non-empty) to build the formal parameters for the pointcut.