Search in sources :

Example 1 with Pointcut

use of org.springframework.aop.Pointcut in project druid by alibaba.

the class StatAnnotationAdvisor method buildPointcut.

protected Pointcut buildPointcut() {
    Pointcut cpc = new AnnotationMatchingPointcut(Stat.class, true);
    Pointcut mpc = AnnotationMatchingPointcut.forMethodAnnotation(Stat.class);
    ComposablePointcut result = new ComposablePointcut(cpc).union(mpc);
    return result;
}
Also used : ComposablePointcut(org.springframework.aop.support.ComposablePointcut) Pointcut(org.springframework.aop.Pointcut) AnnotationMatchingPointcut(org.springframework.aop.support.annotation.AnnotationMatchingPointcut) AnnotationMatchingPointcut(org.springframework.aop.support.annotation.AnnotationMatchingPointcut) ComposablePointcut(org.springframework.aop.support.ComposablePointcut)

Example 2 with Pointcut

use of org.springframework.aop.Pointcut in project spring-framework by spring-projects.

the class CallCountingInterceptor method testMultipleAndSubstitutions.

@Test
public void testMultipleAndSubstitutions() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
    PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String) && this(Object)", expr.getPointcutExpression());
}
Also used : Pointcut(org.springframework.aop.Pointcut) PointcutExpression(org.aspectj.weaver.tools.PointcutExpression) Test(org.junit.Test)

Example 3 with Pointcut

use of org.springframework.aop.Pointcut in project spring-framework by spring-projects.

the class CallCountingInterceptor method testAndSubstitution.

@Test
public void testAndSubstitution() {
    Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
    PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String)", expr.getPointcutExpression());
}
Also used : Pointcut(org.springframework.aop.Pointcut) PointcutExpression(org.aspectj.weaver.tools.PointcutExpression) Test(org.junit.Test)

Example 4 with Pointcut

use of org.springframework.aop.Pointcut in project spring-framework by spring-projects.

the class MethodValidationPostProcessor method afterPropertiesSet.

@Override
public void afterPropertiesSet() {
    Pointcut pointcut = new AnnotationMatchingPointcut(this.validatedAnnotationType, true);
    this.advisor = new DefaultPointcutAdvisor(pointcut, createMethodValidationAdvice(this.validator));
}
Also used : Pointcut(org.springframework.aop.Pointcut) AnnotationMatchingPointcut(org.springframework.aop.support.annotation.AnnotationMatchingPointcut) AnnotationMatchingPointcut(org.springframework.aop.support.annotation.AnnotationMatchingPointcut) DefaultPointcutAdvisor(org.springframework.aop.support.DefaultPointcutAdvisor)

Example 5 with Pointcut

use of org.springframework.aop.Pointcut in project spring-framework by spring-projects.

the class AopUtilsTests method testPointcutCanNeverApply.

@Test
public void testPointcutCanNeverApply() {
    class TestPointcut extends StaticMethodMatcherPointcut {

        @Override
        public boolean matches(Method method, Class<?> clazzy) {
            return false;
        }
    }
    Pointcut no = new TestPointcut();
    assertFalse(AopUtils.canApply(no, Object.class));
}
Also used : Pointcut(org.springframework.aop.Pointcut) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

Pointcut (org.springframework.aop.Pointcut)20 Test (org.junit.Test)14 TestBean (org.springframework.tests.sample.beans.TestBean)10 ITestBean (org.springframework.tests.sample.beans.ITestBean)6 MethodMatcher (org.springframework.aop.MethodMatcher)4 ClassFilter (org.springframework.aop.ClassFilter)3 ComposablePointcut (org.springframework.aop.support.ComposablePointcut)3 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)3 AnnotationMatchingPointcut (org.springframework.aop.support.annotation.AnnotationMatchingPointcut)3 Method (java.lang.reflect.Method)2 PointcutExpression (org.aspectj.weaver.tools.PointcutExpression)2 ProxyFactory (org.springframework.aop.framework.ProxyFactory)2 NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)2 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)1 StaticMethodMatcher (org.springframework.aop.support.StaticMethodMatcher)1 NestedRuntimeException (org.springframework.core.NestedRuntimeException)1