|
|
|
|
@ -25,12 +25,11 @@ import org.springframework.aop.MethodMatcher;
@@ -25,12 +25,11 @@ import org.springframework.aop.MethodMatcher;
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Static utility methods for composing |
|
|
|
|
* {@link org.springframework.aop.MethodMatcher MethodMatchers}. |
|
|
|
|
* Static utility methods for composing {@link MethodMatcher MethodMatchers}. |
|
|
|
|
* |
|
|
|
|
* <p>A MethodMatcher may be evaluated statically (based on method |
|
|
|
|
* and target class) or need further evaluation dynamically |
|
|
|
|
* (based on arguments at the time of method invocation). |
|
|
|
|
* <p>A MethodMatcher may be evaluated statically (based on method and target |
|
|
|
|
* class) or need further evaluation dynamically (based on arguments at the |
|
|
|
|
* time of method invocation). |
|
|
|
|
* |
|
|
|
|
* @author Rod Johnson |
|
|
|
|
* @author Rob Harrop |
|
|
|
|
@ -88,7 +87,7 @@ public abstract class MethodMatchers {
@@ -88,7 +87,7 @@ public abstract class MethodMatchers {
|
|
|
|
|
* asking is the subject on one or more introductions; {@code false} otherwise |
|
|
|
|
* @return whether or not this method matches statically |
|
|
|
|
*/ |
|
|
|
|
public static boolean matches(MethodMatcher mm, Method method, Class targetClass, boolean hasIntroductions) { |
|
|
|
|
public static boolean matches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) { |
|
|
|
|
Assert.notNull(mm, "MethodMatcher must not be null"); |
|
|
|
|
return ((mm instanceof IntroductionAwareMethodMatcher && |
|
|
|
|
((IntroductionAwareMethodMatcher) mm).matches(method, targetClass, hasIntroductions)) || |
|
|
|
|
@ -113,21 +112,21 @@ public abstract class MethodMatchers {
@@ -113,21 +112,21 @@ public abstract class MethodMatchers {
|
|
|
|
|
this.mm2 = mm2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { |
|
|
|
|
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) || |
|
|
|
|
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass) { |
|
|
|
|
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) || |
|
|
|
|
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected boolean matchesClass1(Class targetClass) { |
|
|
|
|
protected boolean matchesClass1(Class<?> targetClass) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected boolean matchesClass2(Class targetClass) { |
|
|
|
|
protected boolean matchesClass2(Class<?> targetClass) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -135,7 +134,7 @@ public abstract class MethodMatchers {
@@ -135,7 +134,7 @@ public abstract class MethodMatchers {
|
|
|
|
|
return this.mm1.isRuntime() || this.mm2.isRuntime(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass, Object[] args) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) { |
|
|
|
|
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -179,12 +178,12 @@ public abstract class MethodMatchers {
@@ -179,12 +178,12 @@ public abstract class MethodMatchers {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected boolean matchesClass1(Class targetClass) { |
|
|
|
|
protected boolean matchesClass1(Class<?> targetClass) { |
|
|
|
|
return this.cf1.matches(targetClass); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected boolean matchesClass2(Class targetClass) { |
|
|
|
|
protected boolean matchesClass2(Class<?> targetClass) { |
|
|
|
|
return this.cf2.matches(targetClass); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -225,12 +224,12 @@ public abstract class MethodMatchers {
@@ -225,12 +224,12 @@ public abstract class MethodMatchers {
|
|
|
|
|
this.mm2 = mm2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { |
|
|
|
|
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) && |
|
|
|
|
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass) { |
|
|
|
|
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -238,7 +237,7 @@ public abstract class MethodMatchers {
@@ -238,7 +237,7 @@ public abstract class MethodMatchers {
|
|
|
|
|
return this.mm1.isRuntime() || this.mm2.isRuntime(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Method method, Class targetClass, Object[] args) { |
|
|
|
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) { |
|
|
|
|
// Because a dynamic intersection may be composed of a static and dynamic part,
|
|
|
|
|
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
|
|
|
|
|
// it will probably be an unsupported operation.
|
|
|
|
|
|