Examples of AspectJExpressionPointcut


Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    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);
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    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);

  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    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);

  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    switch (this.ajType.getPerClause().getKind()) {
      case SINGLETON :
        this.perClausePointcut = Pointcut.TRUE;
        return;
      case PERTARGET : case PERTHIS :
        AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
        ajexp.setLocation("@Aspect annotation on " + aspectClass.getName());
        ajexp.setExpression(findPerClause(aspectClass));
        this.perClausePointcut = ajexp;
        return;
      case PERTYPEWITHIN :
        // Works with a type pattern
        this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    Class<?> [] pointcutParameterTypes = new Class<?>[0];
    if (pointcutParameterNames != null) {
      pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
    }

    AspectJExpressionPointcut ajexp =
        new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
    ajexp.setLocation(annotatedMethod.toString());
    return ajexp;
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

  public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
      int declarationOrderInAspect, String aspectName) {

    validate(aif.getAspectMetadata().getAspectClass());

    AspectJExpressionPointcut ajexp =
        getPointcut(candidateAdviceMethod, aif.getAspectMetadata().getAspectClass());
    if (ajexp == null) {
      return null;
    }
    return new InstantiationModelAwarePointcutAdvisorImpl(
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    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());
    return ajexp;
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

  @Before
  public void setUp() throws Exception {
    this.comparator = new AspectJPrecedenceComparator();
    this.anyOldMethod = getClass().getMethods()[0];
    this.anyOldPointcut = new AspectJExpressionPointcut();
    this.anyOldPointcut.setExpression("execution(* *(..))");
  }
 
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

  private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();

  @Test
  public void testSingleton() throws SecurityException, NoSuchMethodException {
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
    ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

    InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
        new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"),
        TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean");
    assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    assertFalse(ajpa.isPerInstance());
  }

  @Test
  public void testPerTarget() throws SecurityException, NoSuchMethodException {
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
    ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

    InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
        new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
    assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
    assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.