当前位置: 首页>>代码示例>>Java>>正文


Java Pointcut.getMethodMatcher方法代码示例

本文整理汇总了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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Pointcuts.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AspectJExpressionPointcutTests.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AspectJExpressionPointcutTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:AspectJExpressionPointcutTests.java

示例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;
}
 
开发者ID:txazo,项目名称:spring,代码行数:24,代码来源:Pointcuts.java

示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:Pointcuts.java

示例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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ComposablePointcut.java


注:本文中的org.springframework.aop.Pointcut.getMethodMatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。