Top Description Inners Fields Constructors Methods
org.springframework.aop.aspectj.annotation

public abstract Class AbstractAspectJAdvisorFactory

extends Object
implements AspectJAdvisorFactory
Class Inheritance
All Implemented Interfaces
org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory
Known Direct Subclasses
org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory
Imports
java.lang.annotation.Annotation, java.lang.reflect.Constructor, .Field, .Method, java.util.Map, .StringTokenizer, org.apache.commons.logging.Log, .LogFactory, org.aspectj.lang.annotation.After, .AfterReturning, .AfterThrowing, .Around, .Aspect, .Before, .Pointcut, org.aspectj.lang.reflect.AjType, .AjTypeSystem, .PerClauseKind, org.springframework.aop.framework.AopConfigException, org.springframework.core.ParameterNameDiscoverer, org.springframework.core.annotation.AnnotationUtils, org.springframework.lang.Nullable

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.

Authors
Rod Johnson, Adrian Colyer, Juergen Hoeller, Sam Brannen
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
AbstractAspectJAdvisorFactory.AspectJAnnotation

Class modeling an AspectJ annotation, exposing its type enumeration and pointcut String.

private static class
AbstractAspectJAdvisorFactory.AspectJAnnotationParameterNameDiscoverer

ParameterNameDiscoverer implementation that analyzes the arg names specified at the AspectJ annotation level.

protected static enum
AbstractAspectJAdvisorFactory.AspectJAnnotationType

Enum for AspectJ annotation types.

Field Summary

Modifier and TypeField and Description
private static final String
private static final Class<?>[]
protected final Log
logger

Logger available to subclasses.

protected final ParameterNameDiscoverer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
compiledByAjc(Class<?> clazz)

We need to detect this as "code-style" AspectJ aspects should not be interpreted by Spring AOP.

private static AbstractAspectJAdvisorFactory.AspectJAnnotation
findAnnotation(Method method, Class<? extends Annotation> annotationType)

protected static AbstractAspectJAdvisorFactory.AspectJAnnotation
findAspectJAnnotationOnMethod(Method method)

Find and return the first AspectJ annotation on the given method (there should only be one anyway...).

private boolean
public boolean
isAspect(Class<?>
the supposed annotation-style AspectJ class
clazz
)

Implements org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.isAspect.

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.
public void
validate(Class<?>
the supposed AspectJ annotation-style class to validate
aspectClass
)

Implements org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.validate.

Is the given class a valid AspectJ aspect class?
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AJC_MAGICback to summary
private static final String AJC_MAGIC
ASPECTJ_ANNOTATION_CLASSESback to summary
private static final Class<?>[] ASPECTJ_ANNOTATION_CLASSES
loggerback to summary
protected final Log logger

Logger available to subclasses.

parameterNameDiscovererback to summary
protected final ParameterNameDiscoverer parameterNameDiscoverer

Constructor Detail

AbstractAspectJAdvisorFactoryback to summary
public AbstractAspectJAdvisorFactory()

Method Detail

compiledByAjcback to summary
pack-priv static boolean compiledByAjc(Class<?> clazz)

We need to detect this as "code-style" AspectJ aspects should not be interpreted by Spring AOP.

findAnnotationback to summary
private static AbstractAspectJAdvisorFactory.AspectJAnnotation findAnnotation(Method method, Class<? extends Annotation> annotationType)
Annotations
@Nullable
findAspectJAnnotationOnMethodback to summary
protected static AbstractAspectJAdvisorFactory.AspectJAnnotation findAspectJAnnotationOnMethod(Method method)

Find and return the first AspectJ annotation on the given method (there should only be one anyway...).

Annotations
@SuppressWarnings:unchecked
@Nullable
hasAspectAnnotationback to summary
private boolean hasAspectAnnotation(Class<?> clazz)
isAspectback to summary
public boolean isAspect(Class<?> clazz)

Implements org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.isAspect.

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.

Parameters
clazz:Class<?>

Doc from org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.isAspect.

the supposed annotation-style AspectJ class

Returns:boolean

Doc from org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.isAspect.

whether this class is recognized by AspectJ as an aspect class

Annotations
@Override
validateback to summary
public void validate(Class<?> aspectClass) throws AopConfigException

Implements org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.validate.

Doc from org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory.validate.

Is the given class a valid AspectJ aspect class?

Parameters
aspectClass:Class<?>

the supposed AspectJ annotation-style class to validate

Annotations
@Override
Exceptions
AopConfigException:
if the class is an invalid aspect (which can never be legal)
org.springframework.aop.aspectj.annotation back to summary

protected Class AbstractAspectJAdvisorFactory.AspectJAnnotation

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation

Class modeling an AspectJ annotation, exposing its type enumeration and pointcut String.

Field Summary

Modifier and TypeField and Description
private final Annotation
private final AbstractAspectJAdvisorFactory.AspectJAnnotationType
private static final Map<Class<?>, AbstractAspectJAdvisorFactory.AspectJAnnotationType>
private final String
private static final String[]
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private AbstractAspectJAdvisorFactory.AspectJAnnotationType
public Annotation
public AbstractAspectJAdvisorFactory.AspectJAnnotationType
public String
public String
private String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

annotationback to summary
private final Annotation annotation
annotationTypeback to summary
private final AbstractAspectJAdvisorFactory.AspectJAnnotationType annotationType
annotationTypeMapback to summary
private static final Map<Class<?>, AbstractAspectJAdvisorFactory.AspectJAnnotationType> annotationTypeMap
argumentNamesback to summary
private final String argumentNames
EXPRESSION_ATTRIBUTESback to summary
private static final String[] EXPRESSION_ATTRIBUTES
pointcutExpressionback to summary
private final String pointcutExpression

Constructor Detail

AspectJAnnotationback to summary
public AspectJAnnotation(Annotation annotation)

Method Detail

determineAnnotationTypeback to summary
private AbstractAspectJAdvisorFactory.AspectJAnnotationType determineAnnotationType(Annotation annotation)
getAnnotationback to summary
public Annotation getAnnotation()
getAnnotationTypeback to summary
public AbstractAspectJAdvisorFactory.AspectJAnnotationType getAnnotationType()
getArgumentNamesback to summary
public String getArgumentNames()
getPointcutExpressionback to summary
public String getPointcutExpression()
resolvePointcutExpressionback to summary
private String resolvePointcutExpression(Annotation annotation)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.springframework.aop.aspectj.annotation back to summary

private Class AbstractAspectJAdvisorFactory.AspectJAnnotationParameterNameDiscoverer

extends Object
implements ParameterNameDiscoverer
Class Inheritance
  • java.lang.Object
  • org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotationParameterNameDiscoverer
All Implemented Interfaces
org.springframework.core.ParameterNameDiscoverer

ParameterNameDiscoverer implementation that analyzes the arg names specified at the AspectJ annotation level.

Field Summary

Modifier and TypeField and Description
private static final String[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String[]
getParameterNames(Method
the method to find parameter names for
method
)

Implements org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Return parameter names for a method, or null if they cannot be determined.
public String[]
getParameterNames(Constructor<?>
the constructor to find parameter names for
ctor
)

Implements org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Return parameter names for a constructor, or null if they cannot be determined.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_ARRAYback to summary
private static final String[] EMPTY_ARRAY

Constructor Detail

AspectJAnnotationParameterNameDiscovererback to summary
private AspectJAnnotationParameterNameDiscoverer()

Method Detail

getParameterNamesback to summary
public String[] getParameterNames(Method method)

Implements org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Doc from org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Return parameter names for a method, or null if they cannot be determined.

Individual entries in the array may be null if parameter names are only available for some parameters of the given method but not for others. However, it is recommended to use stub parameter names instead wherever feasible.

Parameters
method:Method

the method to find parameter names for

Returns:String[]

an array of parameter names if the names can be resolved, or null if they cannot

Annotations
@Override
@Nullable
getParameterNamesback to summary
public String[] getParameterNames(Constructor<?> ctor)

Implements org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Doc from org.springframework.core.ParameterNameDiscoverer.getParameterNames.

Return parameter names for a constructor, or null if they cannot be determined.

Individual entries in the array may be null if parameter names are only available for some parameters of the given constructor but not for others. However, it is recommended to use stub parameter names instead wherever feasible.

Parameters
ctor:Constructor<?>

the constructor to find parameter names for

Returns:String[]

an array of parameter names if the names can be resolved, or null if they cannot

Annotations
@Override
@Nullable
org.springframework.aop.aspectj.annotation back to summary

protected final Enum AbstractAspectJAdvisorFactory.AspectJAnnotationType

extends Enum<AbstractAspectJAdvisorFactory.AspectJAnnotationType>
Class Inheritance

Enum for AspectJ annotation types.
See Also
AspectJAnnotation#getAnnotationType()

Field Summary

Modifier and TypeField and Description
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractAspectJAdvisorFactory.AspectJAnnotationType
public static AbstractAspectJAdvisorFactory.AspectJAnnotationType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

AtAfterback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtAfter
AtAfterReturningback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtAfterReturning
AtAfterThrowingback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtAfterThrowing
AtAroundback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtAround
AtBeforeback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtBefore
AtPointcutback to summary
public static final AbstractAspectJAdvisorFactory.AspectJAnnotationType AtPointcut

Constructor Detail

AspectJAnnotationTypeback to summary
private AspectJAnnotationType()

Method Detail

valueOfback to summary
public static AbstractAspectJAdvisorFactory.AspectJAnnotationType valueOf(String name)
valuesback to summary
public static AbstractAspectJAdvisorFactory.AspectJAnnotationType[] values()