The Spring Framework

org.springframework.aop.aspectj
Class AspectJExpressionPointcut

java.lang.Object
  extended by org.springframework.aop.support.AbstractExpressionPointcut
      extended by org.springframework.aop.aspectj.AspectJExpressionPointcut
All Implemented Interfaces:
Serializable, ClassFilter, IntroductionAwareMethodMatcher, MethodMatcher, Pointcut, ExpressionPointcut

public class AspectJExpressionPointcut
extends AbstractExpressionPointcut
implements ClassFilter, IntroductionAwareMethodMatcher

Spring pointcut implementation that uses the AspectJ weaver.

The pointcut expression value is an AspectJ string. 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.

Since:
2.0
Author:
Rob Harrop, Adrian Colyer, Rod Johnson
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.springframework.aop.ClassFilter
TRUE
 
Fields inherited from interface org.springframework.aop.Pointcut
TRUE
 
Constructor Summary
AspectJExpressionPointcut()
          Create a new default AspectJExpressionPointcut.
AspectJExpressionPointcut(Class declarationScope, String[] paramNames, Class[] paramTypes)
          Create a new AspectJExpressionPointcut with the given settings.
AspectJExpressionPointcut(Set supportedPrimitives)
          Create a new AspectJExpressionPointcut with the given supported primitives.
 
Method Summary
 boolean equals(Object other)
           
 ClassFilter getClassFilter()
          Return the ClassFilter for this pointcut.
 MethodMatcher getMethodMatcher()
          Return the MethodMatcher for this pointcut.
 org.aspectj.weaver.tools.PointcutExpression getPointcutExpression()
           
 int hashCode()
           
 boolean isRuntime()
          Is this MethodMatcher dynamic?
 boolean matches(Class targetClass)
          Should the pointcut apply to the given interface or target class?
 boolean matches(Method method, Class targetClass)
          Perform static checking.
 boolean matches(Method method, Class targetClass, boolean beanHasIntroductions)
          Perform static checking.
 boolean matches(Method method, Class targetClass, Object[] args)
          Is there a runtime (dynamic) match for this method, which must have matched statically.
 void setParameterNames(String[] names)
           
 void setParameterTypes(Class[] types)
           
 void setPointcutDeclarationScope(Class pointcutDeclarationScope)
           
 String toString()
           
 
Methods inherited from class org.springframework.aop.support.AbstractExpressionPointcut
getExpression, getLocation, onSetExpression, setExpression, setLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AspectJExpressionPointcut

public AspectJExpressionPointcut()
Create a new default AspectJExpressionPointcut.


AspectJExpressionPointcut

public AspectJExpressionPointcut(Set supportedPrimitives)
Create a new AspectJExpressionPointcut with the given supported primitives.

Parameters:
supportedPrimitives - Set of PointcutPrimitive instances

AspectJExpressionPointcut

public AspectJExpressionPointcut(Class declarationScope,
                                 String[] paramNames,
                                 Class[] paramTypes)
Create a new AspectJExpressionPointcut with the given settings.

Method Detail

setPointcutDeclarationScope

public void setPointcutDeclarationScope(Class pointcutDeclarationScope)

setParameterNames

public void setParameterNames(String[] names)

setParameterTypes

public void setParameterTypes(Class[] types)

getClassFilter

public ClassFilter getClassFilter()
Description copied from interface: Pointcut
Return the ClassFilter for this pointcut.

Specified by:
getClassFilter in interface Pointcut

getMethodMatcher

public MethodMatcher getMethodMatcher()
Description copied from interface: Pointcut
Return the MethodMatcher for this pointcut.

Specified by:
getMethodMatcher in interface Pointcut

getPointcutExpression

public org.aspectj.weaver.tools.PointcutExpression getPointcutExpression()

matches

public boolean matches(Class targetClass)
Description copied from interface: ClassFilter
Should the pointcut apply to the given interface or target class?

Specified by:
matches in interface ClassFilter
Parameters:
targetClass - candidate target class
Returns:
whether the advice should apply to this candidate target class

matches

public boolean matches(Method method,
                       Class targetClass)
Description copied from interface: MethodMatcher
Perform static checking. If this returns false, or if the isRuntime() method returns false, no runtime check will be made.

Specified by:
matches in interface MethodMatcher
Parameters:
method - the candidate method
targetClass - target class (may be null, in which case the candidate class must be taken to be the method's declaring class)
Returns:
whether or not this method matches statically

isRuntime

public boolean isRuntime()
Description copied from interface: MethodMatcher
Is this MethodMatcher dynamic? Must a final call be made on the matches(Method, Class, Object[]) method at runtime even if the 2-arg matches method returns true? Can be invoked when an AOP proxy is created, and need not be invoked again before each method invocation,

Note: Could be pulled up into a Matcher super-interface to apply to fields also.

Specified by:
isRuntime in interface MethodMatcher
Returns:
whether or not a runtime matche via the 3-arg matches() method is required if static matching passed.

matches

public boolean matches(Method method,
                       Class targetClass,
                       boolean beanHasIntroductions)
Description copied from interface: IntroductionAwareMethodMatcher
Perform static checking. If this returns false, or if the isRuntime() method returns false, no runtime check will be made.

Specified by:
matches in interface IntroductionAwareMethodMatcher
Parameters:
method - the candidate method
targetClass - target class (may be null, in which case the candidate class must be taken to be the method's declaring class)
beanHasIntroductions - true if the bean on whose behalf we are asking is the subject on one or more introductions, and false otherwise
Returns:
whether or not this method matches statically

matches

public boolean matches(Method method,
                       Class targetClass,
                       Object[] args)
Description copied from interface: MethodMatcher
Is there a runtime (dynamic) match for this method, which must have matched statically. This method is invoked only if the 2-arg matches method returns true for the given method and target class, and if the isRuntime() method returns true. Invoked immediately before potential running of the advice, after any advice earlier in the advice chain has run.

Specified by:
matches in interface MethodMatcher
Parameters:
method - the candidate method
targetClass - target class
args - arguments to the method
Returns:
whether there's a runtime match
See Also:
MethodMatcher.matches(Method, Class)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

The Spring Framework

Copyright © 2002-2006 The Spring Framework.