spring-framework / org.springframework.aop.aspectj

Package org.springframework.aop.aspectj

Types

AspectJAdviceParameterNameDiscoverer

open class AspectJAdviceParameterNameDiscoverer : ParameterNameDiscoverer

ParameterNameDiscoverer implementation that tries to deduce parameter names for an advice method from the pointcut expression, returning, and throwing clauses. If an unambiguous interpretation is not available, it returns null.

This class interprets arguments in the following way:

  1. If the first parameter of the method is of type JoinPoint or ProceedingJoinPoint, it is assumed to be for passing thisJoinPoint to the advice, and the parameter name will be assigned the value "thisJoinPoint".
  2. If the first parameter of the method is of type JoinPoint.StaticPart, it is assumed to be for passing "thisJoinPointStaticPart" to the advice, and the parameter name will be assigned the value "thisJoinPointStaticPart".
  3. If a throwingName has been set, and there are no unbound arguments of type Throwable+, then an IllegalArgumentException is raised. If there is more than one unbound argument of type Throwable+, then an AmbiguousBindingException is raised. If there is exactly one unbound argument of type Throwable+, then the corresponding parameter name is assigned the value <throwingName>.
  4. If there remain unbound arguments, then the pointcut expression is examined. Let a be the number of annotation-based pointcut expressions (@annotation, @this, @target, @args, @within, @withincode) that are used in binding form. Usage in binding form has itself to be deduced: if the expression inside the pointcut is a single string literal that meets Java variable name conventions it is assumed to be a variable name. If a is zero we proceed to the next stage. If a > 1 then an AmbiguousBindingException is raised. If a == 1, and there are no unbound arguments of type Annotation+, then an IllegalArgumentException is raised. if there is exactly one such argument, then the corresponding parameter name is assigned the value from the pointcut expression.
  5. If a returningName has been set, and there are no unbound arguments then an IllegalArgumentException is raised. If there is more than one unbound argument then an AmbiguousBindingException is raised. If there is exactly one unbound argument then the corresponding parameter name is assigned the value <returningName>.
  6. If there remain unbound arguments, then the pointcut expression is examined once more for this, target, and args pointcut expressions used in the binding form (binding forms are deduced as described for the annotation based pointcuts). If there remains more than one unbound argument of a primitive type (which can only be bound in args) then an AmbiguousBindingException is raised. If there is exactly one argument of a primitive type, then if exactly one args bound variable was found, we assign the corresponding parameter name the variable name. If there were no args bound variables found an IllegalStateException is raised. If there are multiple args bound variables, an AmbiguousBindingException is raised. At this point, if there remains more than one unbound argument we raise an AmbiguousBindingException. If there are no unbound arguments remaining, we are done. If there is exactly one unbound argument remaining, and only one candidate variable name unbound from this, target, or args, it is assigned as the corresponding parameter name. If there are multiple possibilities, an AmbiguousBindingException is raised.

The behavior on raising an IllegalArgumentException or AmbiguousBindingException is configurable to allow this discoverer to be used as part of a chain-of-responsibility. By default the condition will be logged and the getParameterNames(..) method will simply return null. If the raiseExceptions property is set to true, the conditions will be thrown as IllegalArgumentException and AmbiguousBindingException, respectively.

Was that perfectly clear? ;)

Short version: If an unambiguous binding can be deduced, then it is. If the advice requirements cannot possibly be satisfied, then null is returned. By setting the raiseExceptions property to true, descriptive exceptions will be thrown instead of returning null in the case that the parameter names cannot be discovered.

AspectJAopUtils

abstract class AspectJAopUtils

Utility methods for dealing with AspectJ advisors.

AspectJExpressionPointcut

open class AspectJExpressionPointcut : AbstractExpressionPointcut, ClassFilter, IntroductionAwareMethodMatcher, BeanFactoryAware

Spring org.springframework.aop.Pointcut implementation that uses the AspectJ weaver to evaluate a pointcut expression.

The pointcut expression value is an AspectJ expression. This can reference other pointcuts and use composition and other operations.

Naturally, as this is to be processed by Spring AOP's proxy-based model, only method execution pointcuts are supported.

AspectJExpressionPointcutAdvisor

open class AspectJExpressionPointcutAdvisor : AbstractGenericPointcutAdvisor, BeanFactoryAware

Spring AOP Advisor that can be used for any AspectJ pointcut expression.

AspectJPointcutAdvisor

open class AspectJPointcutAdvisor : PointcutAdvisor, Ordered

AspectJPointcutAdvisor that adapts an AbstractAspectJAdvice to the org.springframework.aop.PointcutAdvisor interface.

AspectJProxyUtils

abstract class AspectJProxyUtils

Utility methods for working with AspectJ proxies.

AspectJWeaverMessageHandler

open class AspectJWeaverMessageHandler : IMessageHandler

Implementation of AspectJ's IMessageHandler interface that routes AspectJ weaving messages through the same logging system as the regular Spring messages.

Pass the option...

-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler

to the weaver; for example, specifying the following in a "META-INF/aop.xml file:

<weaver options="..."/>

InstantiationModelAwarePointcutAdvisor

interface InstantiationModelAwarePointcutAdvisor : PointcutAdvisor

Interface to be implemented by Spring AOP Advisors wrapping AspectJ aspects that may have a lazy initialization strategy. For example, a perThis instantiation model would mean lazy initialization of the advice.

MethodInvocationProceedingJoinPoint

open class MethodInvocationProceedingJoinPoint : ProceedingJoinPoint, StaticPart

Implementation of AspectJ ProceedingJoinPoint interface wrapping an AOP Alliance MethodInvocation.

Note: the getThis() method returns the current Spring AOP proxy. The getTarget() method returns the current Spring AOP target (which may be null if there is no target), and is a plain POJO without any advice. If you want to call the object and have the advice take effect, use getThis(). A common example is casting the object to an introduced interface in the implementation of an introduction.

Of course there is no such distinction between target and proxy in AspectJ.

TypePatternClassFilter

open class TypePatternClassFilter : ClassFilter

Spring AOP ClassFilter implementation using AspectJ type matching.