|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.aspectj.AbstractAspectJAdvice
public abstract class AbstractAspectJAdvice
Base class for AOP Alliance Advice
classes
wrapping an AspectJ aspect or an AspectJ-annotated advice method.
Field Summary | |
---|---|
protected Method |
aspectJAdviceMethod
|
protected static String |
JOIN_POINT_KEY
Key used in ReflectiveMethodInvocation userAtributes map for the current joinpoint. |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
AbstractAspectJAdvice(Method aspectJAdviceMethod,
AspectJExpressionPointcut pointcut,
AspectInstanceFactory aspectInstanceFactory)
Create a new AbstractAspectJAdvice for the given advice method. |
Method Summary | |
---|---|
protected Object[] |
argBinding(org.aspectj.lang.JoinPoint jp,
org.aspectj.weaver.tools.JoinPointMatch jpMatch,
Object returnValue,
Throwable t)
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. |
AspectInstanceFactory |
getAspectInstanceFactory()
Return the factory for aspect instances. |
Method |
getAspectJAdviceMethod()
Return the AspectJ-style advice method. |
String |
getAspectName()
The name of the aspect (bean) in which the advice was declared. |
int |
getDeclarationOrder()
The declaration order of the advice member within the aspect. |
protected Class |
getDiscoveredReturningType()
|
protected 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()
Return the order value of this object, with a higher value meaning greater in terms of sorting. |
AspectJExpressionPointcut |
getPointcut()
Return the AspectJ expression pointcut. |
protected Object |
invokeAdviceMethod(org.aspectj.lang.JoinPoint jp,
org.aspectj.weaver.tools.JoinPointMatch jpMatch,
Object returnValue,
Throwable t)
|
protected Object |
invokeAdviceMethod(org.aspectj.weaver.tools.JoinPointMatch jpMatch,
Object returnValue,
Throwable ex)
Invoke the advice method. |
protected Object |
invokeAdviceMethodWithGivenArgs(Object[] args)
|
void |
setArgumentNames(String argNames)
Set by creator of this advice object if the argument names are known. |
void |
setArgumentNamesFromStringArray(String[] args)
|
void |
setAspectName(String name)
|
void |
setDeclarationOrder(int order)
Sets the declaration order of this advice within the aspect |
void |
setReturningName(String name)
|
protected void |
setReturningNameNoCheck(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(String name)
|
protected void |
setThrowingNameNoCheck(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. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.aop.aspectj.AspectJPrecedenceInformation |
---|
isAfterAdvice, isBeforeAdvice |
Field Detail |
---|
protected static final String JOIN_POINT_KEY
protected final Method aspectJAdviceMethod
Constructor Detail |
---|
public AbstractAspectJAdvice(Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory)
aspectJAdviceMethod
- the AspectJ-style advice methodpointcut
- the AspectJ expression pointcutaspectInstanceFactory
- the factory for aspect instancesMethod Detail |
---|
public static org.aspectj.lang.JoinPoint currentJoinPoint()
Do not use if access is available to the current ReflectiveMethodInvocation (in an around advice).
public final Method getAspectJAdviceMethod()
public final AspectJExpressionPointcut getPointcut()
public final Pointcut buildSafePointcut()
getPointcut()
public final AspectInstanceFactory getAspectInstanceFactory()
public int getOrder()
Ordered
Normally starting with 0 or 1, with Ordered.LOWEST_PRECEDENCE
indicating greatest. Same order values will result in arbitrary
positions for the affected objects.
Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).
Note that order values below 0 are reserved for framework purposes. Application-specified values should always be 0 or greater, with only framework components (internal or third-party) supposed to use lower values.
Ordered.LOWEST_PRECEDENCE
public void setAspectName(String name)
public String getAspectName()
AspectJPrecedenceInformation
getAspectName
in interface AspectJPrecedenceInformation
public void setDeclarationOrder(int order)
public int getDeclarationOrder()
AspectJPrecedenceInformation
getDeclarationOrder
in interface AspectJPrecedenceInformation
public void setArgumentNames(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(String[] args)
public void setReturningName(String name)
protected void setReturningNameNoCheck(String name)
protected Class getDiscoveredReturningType()
public void setThrowingName(String name)
protected void setThrowingNameNoCheck(String name)
protected 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 ParameterNameDiscoverer createParameterNameDiscoverer()
The default implementation creates a PrioritizedParameterNameDiscoverer
containing a LocalVariableTableParameterNameDiscoverer
and an
AspectJAdviceParameterNameDiscoverer
.
protected Object[] argBinding(org.aspectj.lang.JoinPoint jp, org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable t)
jpMatch
- the join point match that matched this execution join pointreturnValue
- the return value from the method execution (may be null)t
- the exception thrown by the method execution (may be null)
protected Object invokeAdviceMethod(org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable ex) throws 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)
Throwable
- in case of invocation failureprotected Object invokeAdviceMethod(org.aspectj.lang.JoinPoint jp, org.aspectj.weaver.tools.JoinPointMatch jpMatch, Object returnValue, Throwable t) throws Throwable
Throwable
protected Object invokeAdviceMethodWithGivenArgs(Object[] args) throws Throwable
Throwable
protected org.aspectj.lang.JoinPoint getJoinPoint()
protected org.aspectj.weaver.tools.JoinPointMatch getJoinPointMatch()
protected org.aspectj.weaver.tools.JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi)
public String toString()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |