Search in sources :

Example 6 with AspectJExpressionPointcut

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

the class ReflectiveAspectJAdvisorFactory method getPointcut.

private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
    AspectJAnnotation<?> aspectJAnnotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
    if (aspectJAnnotation == null) {
        return null;
    }
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
    ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
    ajexp.setBeanFactory(this.beanFactory);
    return ajexp;
}
Also used : AspectJExpressionPointcut(org.springframework.aop.aspectj.AspectJExpressionPointcut)

Example 7 with AspectJExpressionPointcut

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

the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcut.

@Test
public void manualGroovyBeanWithDynamicPointcut() throws Exception {
    TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
    testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", false);
}
Also used : ResourceScriptSource(org.springframework.scripting.support.ResourceScriptSource) AspectJExpressionPointcut(org.springframework.aop.aspectj.AspectJExpressionPointcut) DefaultPointcutAdvisor(org.springframework.aop.support.DefaultPointcutAdvisor) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 8 with AspectJExpressionPointcut

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

the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcutProxyTargetClass.

@Test
public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
    TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
    testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
Also used : ResourceScriptSource(org.springframework.scripting.support.ResourceScriptSource) AspectJExpressionPointcut(org.springframework.aop.aspectj.AspectJExpressionPointcut) DefaultPointcutAdvisor(org.springframework.aop.support.DefaultPointcutAdvisor) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Aggregations

AspectJExpressionPointcut (org.springframework.aop.aspectj.AspectJExpressionPointcut)8 Test (org.junit.Test)5 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)3 ClassPathResource (org.springframework.core.io.ClassPathResource)3 ResourceScriptSource (org.springframework.scripting.support.ResourceScriptSource)3 TestBean (org.springframework.tests.sample.beans.TestBean)2 Before (org.junit.Before)1 PerTargetAspect (test.aop.PerTargetAspect)1