public abstract class AbstractAspectJAdvice extends java.lang.Object implements Advice, AspectJPrecedenceInformation, java.io.Serializable
Advice
classes
wrapping an AspectJ aspect or an AspectJ-annotated advice method.Modifier and Type | Field and Description |
---|---|
protected java.lang.reflect.Method |
aspectJAdviceMethod |
protected static java.lang.String |
JOIN_POINT_KEY
Key used in ReflectiveMethodInvocation userAtributes map for the current joinpoint.
|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractAspectJAdvice(java.lang.reflect.Method aspectJAdviceMethod,
AspectJExpressionPointcut pointcut,
AspectInstanceFactory aspectInstanceFactory)
Create a new AbstractAspectJAdvice for the given advice method.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object[] |
argBinding(org.aspectj.lang.JoinPoint jp,
org.aspectj.weaver.tools.JoinPointMatch jpMatch,
java.lang.Object returnValue,
java.lang.Throwable ex)
Take the arguments at the method execution join point and output a set of arguments
to the advice method.
|
Pointcut |
buildSafePointcut()
Build a 'safe' pointcut that excludes the AspectJ advice method itself.
|
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.
|
protected ParameterNameDiscoverer |
createParameterNameDiscoverer()
Create a ParameterNameDiscoverer to be used for argument binding.
|
static org.aspectj.lang.JoinPoint |
currentJoinPoint()
Lazily instantiate joinpoint for the current invocation.
|
java.lang.ClassLoader |
getAspectClassLoader()
Return the ClassLoader for aspect instances.
|
AspectInstanceFactory |
getAspectInstanceFactory()
Return the factory for aspect instances.
|
java.lang.reflect.Method |
getAspectJAdviceMethod()
Return the AspectJ-style advice method.
|
java.lang.String |
getAspectName()
Return the name of the aspect (bean) in which the advice was declared.
|
int |
getDeclarationOrder()
Return the declaration order of the advice member within the aspect.
|
protected java.lang.reflect.Type |
getDiscoveredReturningGenericType() |
protected java.lang.Class<?> |
getDiscoveredReturningType() |
protected java.lang.Class<?> |
getDiscoveredThrowingType() |
protected org.aspectj.lang.JoinPoint |
getJoinPoint()
Overridden in around advice to return proceeding join point.
|
protected org.aspectj.weaver.tools.JoinPointMatch |
getJoinPointMatch()
Get the current join point match at the join point we are being dispatched on.
|
protected org.aspectj.weaver.tools.JoinPointMatch |
getJoinPointMatch(ProxyMethodInvocation pmi) |
int |
getOrder()
Get the order value of this object.
|
AspectJExpressionPointcut |
getPointcut()
Return the AspectJ expression pointcut.
|
protected java.lang.Object |
invokeAdviceMethod(org.aspectj.lang.JoinPoint jp,
org.aspectj.weaver.tools.JoinPointMatch jpMatch,
java.lang.Object returnValue,
java.lang.Throwable t) |
protected java.lang.Object |
invokeAdviceMethod(org.aspectj.weaver.tools.JoinPointMatch jpMatch,
java.lang.Object returnValue,
java.lang.Throwable ex)
Invoke the advice method.
|
protected java.lang.Object |
invokeAdviceMethodWithGivenArgs(java.lang.Object[] args) |
void |
setArgumentNames(java.lang.String argNames)
Set by creator of this advice object if the argument names are known.
|
void |
setArgumentNamesFromStringArray(java.lang.String... args) |
void |
setAspectName(java.lang.String name)
Set the name of the aspect (bean) in which the advice was declared.
|
void |
setDeclarationOrder(int order)
Set the declaration order of this advice within the aspect.
|
void |
setReturningName(java.lang.String name) |
protected void |
setReturningNameNoCheck(java.lang.String name)
We need to hold the returning name at this level for argument binding calculations,
this method allows the afterReturning advice subclass to set the name.
|
void |
setThrowingName(java.lang.String name) |
protected void |
setThrowingNameNoCheck(java.lang.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 boolean |
supportsProceedingJoinPoint() |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isAfterAdvice, isBeforeAdvice
protected static final java.lang.String JOIN_POINT_KEY
protected transient java.lang.reflect.Method aspectJAdviceMethod
public AbstractAspectJAdvice(java.lang.reflect.Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory)
aspectJAdviceMethod
- the AspectJ-style advice methodpointcut
- the AspectJ expression pointcutaspectInstanceFactory
- the factory for aspect instancespublic static org.aspectj.lang.JoinPoint currentJoinPoint()
Do not use if access is available to the current ReflectiveMethodInvocation (in an around advice).
public final java.lang.reflect.Method getAspectJAdviceMethod()
public final AspectJExpressionPointcut getPointcut()
public final Pointcut buildSafePointcut()
getPointcut()
public final AspectInstanceFactory getAspectInstanceFactory()
@Nullable public final java.lang.ClassLoader getAspectClassLoader()
public int getOrder()
Ordered
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-startup
values).
Same order values will result in arbitrary sort positions for the affected objects.
getOrder
in interface Ordered
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
public void setAspectName(java.lang.String name)
public java.lang.String getAspectName()
AspectJPrecedenceInformation
getAspectName
in interface AspectJPrecedenceInformation
public void setDeclarationOrder(int order)
public int getDeclarationOrder()
AspectJPrecedenceInformation
getDeclarationOrder
in interface AspectJPrecedenceInformation
public void setArgumentNames(java.lang.String argNames)
This could be for example because they have been explicitly specified in XML, or in an advice annotation.
argNames
- comma delimited list of arg namespublic void setArgumentNamesFromStringArray(java.lang.String... args)
public void setReturningName(java.lang.String name)
protected void setReturningNameNoCheck(java.lang.String name)
protected java.lang.Class<?> getDiscoveredReturningType()
@Nullable protected java.lang.reflect.Type getDiscoveredReturningGenericType()
public void setThrowingName(java.lang.String name)
protected void setThrowingNameNoCheck(java.lang.String name)
protected java.lang.Class<?> getDiscoveredThrowingType()
public final void calculateArgumentBindings()
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.StaticPart
then we pass a JoinPoint.StaticPart
in 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.
protected boolean supportsProceedingJoinPoint()
protected ParameterNameDiscoverer createParameterNameDiscoverer()
The default implementation creates a DefaultParameterNameDiscoverer
and adds a specifically configured AspectJAdviceParameterNameDiscoverer
.
protected java.lang.Object[] argBinding(org.aspectj.lang.JoinPoint jp, @Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable java.lang.Object returnValue, @Nullable java.lang.Throwable ex)
jp
- the current JoinPointjpMatch
- the join point match that matched this execution join pointreturnValue
- the return value from the method execution (may be null)ex
- the exception thrown by the method execution (may be null)protected java.lang.Object invokeAdviceMethod(@Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable java.lang.Object returnValue, @Nullable java.lang.Throwable ex) throws java.lang.Throwable
jpMatch
- the JoinPointMatch that matched this execution join pointreturnValue
- the return value from the method execution (may be null)ex
- the exception thrown by the method execution (may be null)java.lang.Throwable
- in case of invocation failureprotected java.lang.Object invokeAdviceMethod(org.aspectj.lang.JoinPoint jp, @Nullable org.aspectj.weaver.tools.JoinPointMatch jpMatch, @Nullable java.lang.Object returnValue, @Nullable java.lang.Throwable t) throws java.lang.Throwable
java.lang.Throwable
protected java.lang.Object invokeAdviceMethodWithGivenArgs(java.lang.Object[] args) throws java.lang.Throwable
java.lang.Throwable
protected org.aspectj.lang.JoinPoint getJoinPoint()
@Nullable protected org.aspectj.weaver.tools.JoinPointMatch getJoinPointMatch()
@Nullable protected org.aspectj.weaver.tools.JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi)
public java.lang.String toString()
toString
in class java.lang.Object