use of org.springframework.aop.aspectj.AspectJExpressionPointcut in project spring-framework by spring-projects.
the class AspectJPrecedenceComparatorTests method setUp.
@Before
public void setUp() throws Exception {
this.comparator = new AspectJPrecedenceComparator();
this.anyOldMethod = getClass().getMethods()[0];
this.anyOldPointcut = new AspectJExpressionPointcut();
this.anyOldPointcut.setExpression("execution(* *(..))");
}
use of org.springframework.aop.aspectj.AspectJExpressionPointcut in project spring-framework by spring-projects.
the class AspectJPointcutAdvisorTests method testSingleton.
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(ajexp, TestBean.class.getMethod("getAge"), af, new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null), "someBean"), 1, "someBean");
assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertFalse(ajpa.isPerInstance());
}
use of org.springframework.aop.aspectj.AspectJExpressionPointcut in project spring-framework by spring-projects.
the class AspectJPointcutAdvisorTests method testPerTarget.
@Test
public void testPerTarget() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(ajexp, TestBean.class.getMethod("getAge"), af, new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean"), 1, "someBean");
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
assertTrue(ajpa.isPerInstance());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), TestBean.class));
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), TestBean.class));
}
use of org.springframework.aop.aspectj.AspectJExpressionPointcut in project spring-framework by spring-projects.
the class ReflectiveAspectJAdvisorFactory method getAdvisor.
@Override
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrderInAspect, String aspectName) {
validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());
AspectJExpressionPointcut expressionPointcut = getPointcut(candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
if (expressionPointcut == null) {
return null;
}
return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod, this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
use of org.springframework.aop.aspectj.AspectJExpressionPointcut in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithStaticPointcut.
@Test
public void manualGroovyBeanWithStaticPointcut() throws Exception {
TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression(String.format("execution(* %s.TestService+.*(..))", ClassUtils.getPackageName(getClass())));
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
Aggregations