本文整理汇总了Java中org.springframework.aop.Pointcut.getMethodMatcher方法的典型用法代码示例。如果您正苦于以下问题:Java Pointcut.getMethodMatcher方法的具体用法?Java Pointcut.getMethodMatcher怎么用?Java Pointcut.getMethodMatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.Pointcut
的用法示例。
在下文中一共展示了Pointcut.getMethodMatcher方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
/**
* Perform the least expensive check for a pointcut match.
* @param pointcut the pointcut to match
* @param method the candidate method
* @param targetClass the target class
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object[] args) {
Assert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
}
if (pointcut.getClassFilter().matches(targetClass)) {
// Only check if it gets past first hurdle.
MethodMatcher mm = pointcut.getMethodMatcher();
if (mm.matches(method, targetClass)) {
// We may need additional runtime (argument) check.
return (!mm.isRuntime() || mm.matches(method, targetClass, args));
}
}
return false;
}
示例2: testMatchExplicit
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
assertMatchesTestBeanClass(classFilter);
// not currently testable in a reliable fashion
//assertDoesNotMatchStringClass(classFilter);
assertFalse("Should not be a runtime match", methodMatcher.isRuntime());
assertMatchesGetAge(methodMatcher);
assertFalse("Expression should match setAge() method", methodMatcher.matches(setAge, TestBean.class));
}
示例3: testMatchWithTypePattern
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
@Test
public void testMatchWithTypePattern() throws Exception {
String expression = "execution(* *..TestBean.*Age(..))";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
assertMatchesTestBeanClass(classFilter);
// not currently testable in a reliable fashion
//assertDoesNotMatchStringClass(classFilter);
assertFalse("Should not be a runtime match", methodMatcher.isRuntime());
assertMatchesGetAge(methodMatcher);
assertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.class));
}
示例4: testMatchWithArgs
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
assertMatchesTestBeanClass(classFilter);
// not currently testable in a reliable fashion
//assertDoesNotMatchStringClass(classFilter);
assertTrue("Should match with setSomeNumber with Double input",
methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
assertFalse("Should not match setSomeNumber with Integer input",
methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
示例5: matches
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
/**
* Perform the least expensive check for a pointcut match.
* @param pointcut the pointcut to match
* @param method the candidate method
* @param targetClass the target class
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object... args) {
Assert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
}
if (pointcut.getClassFilter().matches(targetClass)) {
// Only check if it gets past first hurdle.
MethodMatcher mm = pointcut.getMethodMatcher();
if (mm.matches(method, targetClass)) {
// We may need additional runtime (argument) check.
return (!mm.isRuntime() || mm.matches(method, targetClass, args));
}
}
return false;
}
示例6: matches
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
/**
* Perform the least expensive check for a pointcut match.
* @param pointcut the pointcut to match
* @param method the candidate method
* @param targetClass the target class
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Class targetClass, Object[] args) {
Assert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
}
if (pointcut.getClassFilter().matches(targetClass)) {
// Only check if it gets past first hurdle.
MethodMatcher mm = pointcut.getMethodMatcher();
if (mm.matches(method, targetClass)) {
// We may need additional runtime (argument) check.
return (!mm.isRuntime() || mm.matches(method, targetClass, args));
}
}
return false;
}
示例7: ComposablePointcut
import org.springframework.aop.Pointcut; //导入方法依赖的package包/类
/**
* Create a ComposablePointcut based on the given Pointcut.
* @param pointcut the original Pointcut
*/
public ComposablePointcut(Pointcut pointcut) {
Assert.notNull(pointcut, "Pointcut must not be null");
this.classFilter = pointcut.getClassFilter();
this.methodMatcher = pointcut.getMethodMatcher();
}