Top Description Fields Constructors Methods
org.springframework.aop.support

public Class ControlFlowPointcut

extends Object
implements Pointcut, ClassFilter, MethodMatcher, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.springframework.aop.MethodMatcher, org.springframework.aop.ClassFilter, org.springframework.aop.Pointcut
Annotations
@SuppressWarnings:serial
Imports
java.io.Serializable, java.lang.reflect.Method, java.util.Arrays, .Collections, .List, java.util.concurrent.atomic.AtomicInteger, org.springframework.aop.ClassFilter, .MethodMatcher, .Pointcut, org.springframework.lang.Nullable, org.springframework.util.Assert, .PatternMatchUtils

Pointcut and method matcher for use as a simple cflow-style pointcut.

Each configured method name pattern can be an exact method name or a pattern (see isMatch(String, String) for details on the supported pattern styles).

Note that evaluating such pointcuts is 10-15 times slower than evaluating normal pointcuts, but they are useful in some cases.

Authors
Rod Johnson, Rob Harrop, Juergen Hoeller, Sam Brannen
See Also
NameMatchMethodPointcut, JdkRegexpMethodPointcut

Field Summary

Modifier and TypeField and Description
protected final Class<?>
clazz

The class against which to match.

private final AtomicInteger
protected final List<String>
methodNamePatterns

An immutable list of distinct method name patterns against which to match.

Constructor Summary

AccessConstructor and Description
public
ControlFlowPointcut(Class<?>
the class
clazz
)

Construct a new pointcut that matches all control flows below the given class.

public
ControlFlowPointcut(Class<?>
the class
clazz
,
String
the method name pattern (may be null)
methodNamePattern
)

Construct a new pointcut that matches all calls below a method matching the given method name pattern in the given class.

public
ControlFlowPointcut(Class<?>
the class
clazz
,
String...
the method name patterns (potentially empty)
methodNamePatterns
)

Construct a new pointcut that matches all calls below a method matching one of the given method name patterns in the given class.

public
ControlFlowPointcut(Class<?>
the class
clazz
,
List<String>
the method name patterns (potentially empty)
methodNamePatterns
)

Construct a new pointcut that matches all calls below a method matching one of the given method name patterns in the given class.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public ClassFilter
getClassFilter()

Implements org.springframework.aop.Pointcut.getClassFilter.

Return the ClassFilter for this pointcut.
public int
getEvaluations()

Get the number of times matches(Method, Class, Object...) has been evaluated.

public MethodMatcher
getMethodMatcher()

Implements org.springframework.aop.Pointcut.getMethodMatcher.

Return the MethodMatcher for this pointcut.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
protected final void
protected boolean

Returns:

true if the method name matches the pattern at the specified index
isMatch
(String
the method name to check
methodName
,
int
the index of the method name pattern
patternIndex
)

Determine if the given method name matches the method name pattern at the specified index.

protected boolean

Returns:

true if the method name matches the pattern
isMatch
(String
the method name to check
methodName
,
String
the method name pattern
methodNamePattern
)

Determine if the given method name matches the method name pattern.

public boolean
isRuntime()

Implements org.springframework.aop.MethodMatcher.isRuntime.

Is this MethodMatcher dynamic, that is, must a final check be made via the matches(Method, Class, Object[]) method at runtime even if matches(Method, Class) returns true?
public boolean
matches(Class<?>
the candidate target class
clazz
)

Implements org.springframework.aop.ClassFilter.matches.

Subclasses can override this for greater filtering (and performance).
public boolean
matches(Method
the candidate method
method
,
Class<?>
the target class
targetClass
)

Implements org.springframework.aop.MethodMatcher.matches.

Subclasses can override this if it's possible to filter out some candidate classes.
public boolean
matches(Method
the candidate method
method
,
Class<?>
the target class
targetClass
,
Object...
arguments to the method
args
)

Implements org.springframework.aop.MethodMatcher.matches.

Check whether there is a runtime (dynamic) match for this method, which must have matched statically.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

clazzback to summary
protected final Class<?> clazz

The class against which to match.

Since
6.1
evaluationCountback to summary
private final AtomicInteger evaluationCount
methodNamePatternsback to summary
protected final List<String> methodNamePatterns

An immutable list of distinct method name patterns against which to match.

Since
6.1

Constructor Detail

ControlFlowPointcutback to summary
public ControlFlowPointcut(Class<?> clazz)

Construct a new pointcut that matches all control flows below the given class.

Parameters
clazz:Class<?>

the class

ControlFlowPointcutback to summary
public ControlFlowPointcut(Class<?> clazz, String methodNamePattern)

Construct a new pointcut that matches all calls below a method matching the given method name pattern in the given class.

If no method name pattern is given, the pointcut matches all control flows below the given class.

Parameters
clazz:Class<?>

the class

methodNamePattern:String

the method name pattern (may be null)

ControlFlowPointcutback to summary
public ControlFlowPointcut(Class<?> clazz, String... methodNamePatterns)

Construct a new pointcut that matches all calls below a method matching one of the given method name patterns in the given class.

If no method name pattern is given, the pointcut matches all control flows below the given class.

Parameters
clazz:Class<?>

the class

methodNamePatterns:String[]

the method name patterns (potentially empty)

Since
6.1
ControlFlowPointcutback to summary
public ControlFlowPointcut(Class<?> clazz, List<String> methodNamePatterns)

Construct a new pointcut that matches all calls below a method matching one of the given method name patterns in the given class.

If no method name pattern is given, the pointcut matches all control flows below the given class.

Parameters
clazz:Class<?>

the class

methodNamePatterns:List<String>

the method name patterns (potentially empty)

Since
6.1

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getClassFilterback to summary
public ClassFilter getClassFilter()

Implements org.springframework.aop.Pointcut.getClassFilter.

Doc from org.springframework.aop.Pointcut.getClassFilter.

Return the ClassFilter for this pointcut.

Returns:ClassFilter

the ClassFilter (never null)

Annotations
@Override
getEvaluationsback to summary
public int getEvaluations()

Get the number of times matches(Method, Class, Object...) has been evaluated.

Useful for optimization and testing purposes.

getMethodMatcherback to summary
public MethodMatcher getMethodMatcher()

Implements org.springframework.aop.Pointcut.getMethodMatcher.

Doc from org.springframework.aop.Pointcut.getMethodMatcher.

Return the MethodMatcher for this pointcut.

Returns:MethodMatcher

the MethodMatcher (never null)

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
incrementEvaluationCountback to summary
protected final void incrementEvaluationCount()

Increment the evaluation count.

Since
6.1
See Also
matches(Method, Class, Object...)
isMatchback to summary
protected boolean isMatch(String methodName, int patternIndex)

Determine if the given method name matches the method name pattern at the specified index.

This method is invoked by matches(Method, Class, Object...).

The default implementation retrieves the method name pattern from methodNamePatterns and delegates to isMatch(String, String).

Can be overridden in subclasses — for example, to support regular expressions.

Parameters
methodName:String

the method name to check

patternIndex:int

the index of the method name pattern

Returns:boolean

true if the method name matches the pattern at the specified index

Since
6.1
See Also
methodNamePatterns, isMatch(String, String), matches(Method, Class, Object...)
isMatchback to summary
protected boolean isMatch(String methodName, String methodNamePattern)

Determine if the given method name matches the method name pattern.

This method is invoked by isMatch(String, int).

The default implementation checks for direct equality as well as xxx*, *xxx, *xxx*, and xxx*yyy matches.

Can be overridden in subclasses — for example, to support a different style of simple pattern matching.

Parameters
methodName:String

the method name to check

methodNamePattern:String

the method name pattern

Returns:boolean

true if the method name matches the pattern

Since
6.1
See Also
isMatch(String, int), PatternMatchUtils#simpleMatch(String, String)
isRuntimeback to summary
public boolean isRuntime()

Implements org.springframework.aop.MethodMatcher.isRuntime.

Doc from org.springframework.aop.MethodMatcher.isRuntime.

Is this MethodMatcher dynamic, that is, must a final check be made via the matches(Method, Class, Object[]) method at runtime even if matches(Method, Class) returns true?

Can be invoked when an AOP proxy is created, and need not be invoked again before each method invocation.

Returns:boolean

whether a runtime match via matches(Method, Class, Object[]) is required if static matching passed

Annotations
@Override
matchesback to summary
public boolean matches(Class<?> clazz)

Implements org.springframework.aop.ClassFilter.matches.

Subclasses can override this for greater filtering (and performance).

The default implementation always returns true.

Parameters
clazz:Class<?>

Doc from org.springframework.aop.ClassFilter.matches.

the candidate target class

Returns:boolean

Doc from org.springframework.aop.ClassFilter.matches.

whether the advice should apply to the given target class

Annotations
@Override
matchesback to summary
public boolean matches(Method method, Class<?> targetClass)

Implements org.springframework.aop.MethodMatcher.matches.

Subclasses can override this if it's possible to filter out some candidate classes.

The default implementation always returns true.

Parameters
method:Method

Doc from org.springframework.aop.MethodMatcher.matches.

the candidate method

targetClass:Class<?>

Doc from org.springframework.aop.MethodMatcher.matches.

the target class

Returns:boolean

Doc from org.springframework.aop.MethodMatcher.matches.

whether this method matches statically

Annotations
@Override
matchesback to summary
public boolean matches(Method method, Class<?> targetClass, Object... args)

Implements org.springframework.aop.MethodMatcher.matches.

Doc from org.springframework.aop.MethodMatcher.matches.

Check whether there is a runtime (dynamic) match for this method, which must have matched statically.

This method is invoked only if matches(Method, Class) returns true for the given method and target class, and if isRuntime() returns true.

Invoked immediately before potential running of the advice, after any advice earlier in the advice chain has run.

Parameters
method:Method

the candidate method

targetClass:Class<?>

the target class

args:Object[]

arguments to the method

Returns:boolean

whether there's a runtime match

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override