Java Code Examples for org.springframework.aop.Pointcut#getClassFilter()

The following examples show how to use org.springframework.aop.Pointcut#getClassFilter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AspectJExpressionPointcutTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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));
}
 
Example 2
Source File: AspectJExpressionPointcutTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 3
Source File: AspectJExpressionPointcutTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 4
Source File: AspectJExpressionPointcutTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 5
Source File: AspectJExpressionPointcutTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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 Double(12)));
	assertFalse("Should not match setSomeNumber with Integer input",
			methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11)));
	assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class));
	assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
 
Example 6
Source File: AspectJExpressionPointcutTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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));
}
 
Example 7
Source File: AspectJExpressionPointcutTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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 Double(12)));
	assertFalse("Should not match setSomeNumber with Integer input",
			methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11)));
	assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class));
	assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
 
Example 8
Source File: AspectJExpressionPointcutTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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));
}
 
Example 9
Source File: AspectJExpressionPointcutTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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));
}
 
Example 10
Source File: AbstractAspectJAdvice.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Build a 'safe' pointcut that excludes the AspectJ advice method itself.
 * @return a composable pointcut that builds on the original AspectJ expression pointcut
 * @see #getPointcut()
 */
public final Pointcut buildSafePointcut() {
	Pointcut pc = getPointcut();
	MethodMatcher safeMethodMatcher = MethodMatchers.intersection(
			new AdviceExcludingMethodMatcher(this.aspectJAdviceMethod), pc.getMethodMatcher());
	return new ComposablePointcut(pc.getClassFilter(), safeMethodMatcher);
}
 
Example 11
Source File: AbstractAspectJAdvice.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Build a 'safe' pointcut that excludes the AspectJ advice method itself.
 * @return a composable pointcut that builds on the original AspectJ expression pointcut
 * @see #getPointcut()
 */
public final Pointcut buildSafePointcut() {
	Pointcut pc = getPointcut();
	MethodMatcher safeMethodMatcher = MethodMatchers.intersection(
			new AdviceExcludingMethodMatcher(this.aspectJAdviceMethod), pc.getMethodMatcher());
	return new ComposablePointcut(pc.getClassFilter(), safeMethodMatcher);
}
 
Example 12
Source File: AbstractAspectJAdvice.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Build a 'safe' pointcut that excludes the AspectJ advice method itself.
 * @return a composable pointcut that builds on the original AspectJ expression pointcut
 * @see #getPointcut()
 */
public final Pointcut buildSafePointcut() {
	Pointcut pc = getPointcut();
	MethodMatcher safeMethodMatcher = MethodMatchers.intersection(
			new AdviceExcludingMethodMatcher(this.aspectJAdviceMethod), pc.getMethodMatcher());
	return new ComposablePointcut(pc.getClassFilter(), safeMethodMatcher);
}
 
Example 13
Source File: AbstractAspectJAdvice.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Build a 'safe' pointcut that excludes the AspectJ advice method itself.
 * @return a composable pointcut that builds on the original AspectJ expression pointcut
 * @see #getPointcut()
 */
public final Pointcut buildSafePointcut() {
	Pointcut pc = getPointcut();
	MethodMatcher safeMethodMatcher = MethodMatchers.intersection(
			new AdviceExcludingMethodMatcher(this.aspectJAdviceMethod), pc.getMethodMatcher());
	return new ComposablePointcut(pc.getClassFilter(), safeMethodMatcher);
}
 
Example 14
Source File: ComposablePointcut.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * 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();
}
 
Example 15
Source File: ComposablePointcut.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
}
 
Example 16
Source File: ComposablePointcut.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
}
 
Example 17
Source File: ComposablePointcut.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * 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();
}