28
28
import org .springframework .util .ObjectUtils ;
29
29
30
30
/**
31
- * Pointcut and method matcher for use in simple <b>cflow</b>-style pointcut.
32
- * Note that evaluating such pointcuts is 10-15 times slower than evaluating
31
+ * Pointcut and method matcher for use as a simple <b>cflow</b>-style pointcut.
32
+ *
33
+ * <p>Note that evaluating such pointcuts is 10-15 times slower than evaluating
33
34
* normal pointcuts, but they are useful in some cases.
34
35
*
35
36
* @author Rod Johnson
@@ -45,22 +46,23 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
45
46
@ Nullable
46
47
private final String methodName ;
47
48
48
- private final AtomicInteger evaluations = new AtomicInteger ();
49
+ private final AtomicInteger evaluationCount = new AtomicInteger ();
49
50
50
51
51
52
/**
52
- * Construct a new pointcut that matches all control flows below that class.
53
- * @param clazz the clazz
53
+ * Construct a new pointcut that matches all control flows below the given class.
54
+ * @param clazz the class
54
55
*/
55
56
public ControlFlowPointcut (Class <?> clazz ) {
56
57
this (clazz , null );
57
58
}
58
59
59
60
/**
60
61
* Construct a new pointcut that matches all calls below the given method
61
- * in the given class. If no method name is given, matches all control flows
62
+ * in the given class.
63
+ * <p>If no method name is given, the pointcut matches all control flows
62
64
* below the given class.
63
- * @param clazz the clazz
65
+ * @param clazz the class
64
66
* @param methodName the name of the method (may be {@code null})
65
67
*/
66
68
public ControlFlowPointcut (Class <?> clazz , @ Nullable String methodName ) {
@@ -72,6 +74,7 @@ public ControlFlowPointcut(Class<?> clazz, @Nullable String methodName) {
72
74
73
75
/**
74
76
* Subclasses can override this for greater filtering (and performance).
77
+ * <p>The default implementation always returns {@code true}.
75
78
*/
76
79
@ Override
77
80
public boolean matches (Class <?> clazz ) {
@@ -80,6 +83,7 @@ public boolean matches(Class<?> clazz) {
80
83
81
84
/**
82
85
* Subclasses can override this if it's possible to filter out some candidate classes.
86
+ * <p>The default implementation always returns {@code true}.
83
87
*/
84
88
@ Override
85
89
public boolean matches (Method method , Class <?> targetClass ) {
@@ -93,7 +97,7 @@ public boolean isRuntime() {
93
97
94
98
@ Override
95
99
public boolean matches (Method method , Class <?> targetClass , Object ... args ) {
96
- this .evaluations .incrementAndGet ();
100
+ this .evaluationCount .incrementAndGet ();
97
101
98
102
for (StackTraceElement element : new Throwable ().getStackTrace ()) {
99
103
if (element .getClassName ().equals (this .clazz .getName ()) &&
@@ -105,10 +109,12 @@ public boolean matches(Method method, Class<?> targetClass, Object... args) {
105
109
}
106
110
107
111
/**
108
- * It's useful to know how many times we've fired, for optimization.
112
+ * Get the number of times {@link #matches(Method, Class, Object...)} has been
113
+ * evaluated.
114
+ * <p>Useful for optimization and testing purposes.
109
115
*/
110
116
public int getEvaluations () {
111
- return this .evaluations .get ();
117
+ return this .evaluationCount .get ();
112
118
}
113
119
114
120
0 commit comments