Class AbstractAspectJAdvice
- All Implemented Interfaces:
- Serializable,- Advice,- AspectJPrecedenceInformation,- Ordered
- Direct Known Subclasses:
- AspectJAfterAdvice,- AspectJAfterReturningAdvice,- AspectJAfterThrowingAdvice,- AspectJAroundAdvice,- AspectJMethodBeforeAdvice
Advice classes
 wrapping an AspectJ aspect or an AspectJ-annotated advice method.- Since:
- 2.0
- Author:
- Rod Johnson, Adrian Colyer, Juergen Hoeller, Ramnivas Laddad
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Methodprotected static final StringKey used in ReflectiveMethodInvocation userAttributes map for the current joinpoint.Fields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractAspectJAdvice(Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory) Create a new AbstractAspectJAdvice for the given advice method.
- 
Method SummaryModifier and TypeMethodDescriptionprotected Object[]argBinding(org.aspectj.lang.JoinPoint jp, org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable ex) Take the arguments at the method execution join point and output a set of arguments to the advice method.final PointcutBuild a 'safe' pointcut that excludes the AspectJ advice method itself.final voidDo as much work as we can as part of the set-up so that argument binding on subsequent advice invocations can be as fast as possible.protected ParameterNameDiscovererCreate a ParameterNameDiscoverer to be used for argument binding.static org.aspectj.lang.JoinPointLazily instantiate joinpoint for the current invocation.final ClassLoaderReturn the ClassLoader for aspect instances.final AspectInstanceFactoryReturn the factory for aspect instances.final MethodReturn the AspectJ-style advice method.Return the name of the aspect (bean) in which the advice was declared.intReturn the declaration order of the advice member within the aspect.protected Typeprotected Class<?>protected Class<?>protected org.aspectj.lang.JoinPointOverridden in around advice to return proceeding join point.protected org.aspectj.weaver.tools.JoinPointMatchGet the current join point match at the join point we are being dispatched on.protected org.aspectj.weaver.tools.JoinPointMatchintgetOrder()Get the order value of this object.Return the AspectJ expression pointcut.protected ObjectinvokeAdviceMethod(org.aspectj.lang.JoinPoint jp, org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable t) protected ObjectinvokeAdviceMethod(org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable ex) Invoke the advice method.protected ObjectvoidsetArgumentNames(String argumentNames) Set by the creator of this advice object if the argument names are known.voidsetArgumentNamesFromStringArray(String... argumentNames) Set by the creator of this advice object if the argument names are known.voidsetAspectName(String name) Set the name of the aspect (bean) in which the advice was declared.voidsetDeclarationOrder(int order) Set the declaration order of this advice within the aspect.voidsetReturningName(String name) protected voidWe need to hold the returning name at this level for argument binding calculations, this method allows the afterReturning advice subclass to set the name.voidsetThrowingName(String name) protected voidsetThrowingNameNoCheck(String name) We need to hold the throwing name at this level for argument binding calculations, this method allows the afterThrowing advice subclass to set the name.protected booleantoString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.aop.aspectj.AspectJPrecedenceInformationisAfterAdvice, isBeforeAdvice
- 
Field Details- 
JOIN_POINT_KEYKey used in ReflectiveMethodInvocation userAttributes map for the current joinpoint.
- 
aspectJAdviceMethod
 
- 
- 
Constructor Details- 
AbstractAspectJAdvicepublic AbstractAspectJAdvice(Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory) Create a new AbstractAspectJAdvice for the given advice method.- Parameters:
- aspectJAdviceMethod- the AspectJ-style advice method
- pointcut- the AspectJ expression pointcut
- aspectInstanceFactory- the factory for aspect instances
 
 
- 
- 
Method Details- 
currentJoinPointpublic static org.aspectj.lang.JoinPoint currentJoinPoint()Lazily instantiate joinpoint for the current invocation. Requires MethodInvocation to be bound with ExposeInvocationInterceptor.Do not use if access is available to the current ReflectiveMethodInvocation (in an around advice). - Returns:
- current AspectJ joinpoint, or through an exception if we're not in a Spring AOP invocation.
 
- 
getAspectJAdviceMethodReturn the AspectJ-style advice method.
- 
getPointcutReturn the AspectJ expression pointcut.
- 
buildSafePointcutBuild a 'safe' pointcut that excludes the AspectJ advice method itself.- Returns:
- a composable pointcut that builds on the original AspectJ expression pointcut
- See Also:
 
- 
getAspectInstanceFactoryReturn the factory for aspect instances.
- 
getAspectClassLoaderReturn the ClassLoader for aspect instances.
- 
getOrderpublic int getOrder()Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects. 
- 
setAspectNameSet the name of the aspect (bean) in which the advice was declared.
- 
getAspectNameDescription copied from interface:AspectJPrecedenceInformationReturn the name of the aspect (bean) in which the advice was declared.- Specified by:
- getAspectNamein interface- AspectJPrecedenceInformation
 
- 
setDeclarationOrderpublic void setDeclarationOrder(int order) Set the declaration order of this advice within the aspect.
- 
getDeclarationOrderpublic int getDeclarationOrder()Description copied from interface:AspectJPrecedenceInformationReturn the declaration order of the advice member within the aspect.- Specified by:
- getDeclarationOrderin interface- AspectJPrecedenceInformation
 
- 
setArgumentNamesSet by the creator of this advice object if the argument names are known.This could be for example because they have been explicitly specified in XML or in an advice annotation. - Parameters:
- argumentNames- comma delimited list of argument names
 
- 
setArgumentNamesFromStringArraySet by the creator of this advice object if the argument names are known.This could be for example because they have been explicitly specified in XML or in an advice annotation. - Parameters:
- argumentNames- list of argument names
 
- 
setReturningName
- 
setReturningNameNoCheckWe need to hold the returning name at this level for argument binding calculations, this method allows the afterReturning advice subclass to set the name.
- 
getDiscoveredReturningType
- 
getDiscoveredReturningGenericType
- 
setThrowingName
- 
setThrowingNameNoCheckWe need to hold the throwing name at this level for argument binding calculations, this method allows the afterThrowing advice subclass to set the name.
- 
getDiscoveredThrowingType
- 
calculateArgumentBindingspublic final void calculateArgumentBindings()Do as much work as we can as part of the set-up so that argument binding on subsequent advice invocations can be as fast as possible.If the first argument is of type JoinPoint or ProceedingJoinPoint then we pass a JoinPoint in that position (ProceedingJoinPoint for around advice). If the first argument is of type JoinPoint.StaticPartthen we pass aJoinPoint.StaticPartin that position.Remaining arguments have to be bound by pointcut evaluation at a given join point. We will get back a map from argument name to value. We need to calculate which advice parameter needs to be bound to which argument name. There are multiple strategies for determining this binding, which are arranged in a ChainOfResponsibility. 
- 
supportsProceedingJoinPointprotected boolean supportsProceedingJoinPoint()
- 
createParameterNameDiscovererCreate a ParameterNameDiscoverer to be used for argument binding.The default implementation creates a DefaultParameterNameDiscovererand adds a specifically configuredAspectJAdviceParameterNameDiscoverer.
- 
argBindingprotected Object[] argBinding(org.aspectj.lang.JoinPoint jp, @Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable Object returnValue, @Nullable Throwable ex) Take the arguments at the method execution join point and output a set of arguments to the advice method.- Parameters:
- jp- the current JoinPoint
- jpMatch- the join point match that matched this execution join point
- returnValue- the return value from the method execution (may be null)
- ex- the exception thrown by the method execution (may be null)
- Returns:
- the empty array if there are no arguments
 
- 
invokeAdviceMethodprotected Object invokeAdviceMethod(@Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable Object returnValue, @Nullable Throwable ex) throws Throwable Invoke the advice method.- Parameters:
- jpMatch- the JoinPointMatch that matched this execution join point
- returnValue- the return value from the method execution (may be null)
- ex- the exception thrown by the method execution (may be null)
- Returns:
- the invocation result
- Throws:
- Throwable- in case of invocation failure
 
- 
invokeAdviceMethodprotected Object invokeAdviceMethod(org.aspectj.lang.JoinPoint jp, @Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable Object returnValue, @Nullable Throwable t) throws Throwable - Throws:
- Throwable
 
- 
invokeAdviceMethodWithGivenArgs- Throws:
- Throwable
 
- 
getJoinPointprotected org.aspectj.lang.JoinPoint getJoinPoint()Overridden in around advice to return proceeding join point.
- 
getJoinPointMatchGet the current join point match at the join point we are being dispatched on.
- 
getJoinPointMatch@Nullable protected org.aspectj.weaver.tools.JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) 
- 
toString
 
-