Examples of AspectJExpressionPointcut


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


  protected 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

   * @throws SecurityException
   */
  private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
    String matchesTestBean = which + "(org.springframework.beans.TestBean)";
    String matchesIOther = which + "(org.springframework.beans.IOther)";
    AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
    testBeanPc.setExpression(matchesTestBean);
   
    AspectJExpressionPointcut iOtherPc = new AspectJExpressionPointcut();
    iOtherPc.setExpression(matchesIOther);
   
    assertTrue(testBeanPc.matches(TestBean.class));
    assertTrue(testBeanPc.matches(getAge, TestBean.class));
    assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", null),
        OtherIOther.class));
 
    assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", null),
        OtherIOther.class));
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    // Subpackages are matched by **
    if (matchSubpackages) {
      withinBeansPackage += ".";
    }
    withinBeansPackage = withinBeansPackage + "*)";
    AspectJExpressionPointcut withinBeansPc = new AspectJExpressionPointcut();
    withinBeansPc.setExpression(withinBeansPackage);
   
    assertTrue(withinBeansPc.matches(TestBean.class));
    assertTrue(withinBeansPc.matches(getAge, TestBean.class));
    assertEquals(matchSubpackages, withinBeansPc.matches(BeanFactory.class));
    assertEquals(matchSubpackages, withinBeansPc.matches(
        DefaultListableBeanFactory.class.getMethod("getBeanDefinitionCount", null),
        DefaultListableBeanFactory.class));
    assertFalse(withinBeansPc.matches(String.class));
    assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", null),
        OtherIOther.class));
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

    assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", null),
        OtherIOther.class));
  }
 
  public void testFriendlyErrorOnNoLocationClassMatching() {
    AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
    try {
      pc.matches(ITestBean.class);
      fail();
    }
    catch (IllegalStateException ex) {
      assertTrue(ex.getMessage().indexOf("expression") != -1);
    }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

      assertTrue(ex.getMessage().indexOf("expression") != -1);
    }
  }
 
  public void testFriendlyErrorOnNoLocation2ArgMatching() {
    AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
    try {
      pc.matches(getAge, ITestBean.class);
      fail();
    }
    catch (IllegalStateException ex) {
      assertTrue(ex.getMessage().indexOf("expression") != -1);
    }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

      assertTrue(ex.getMessage().indexOf("expression") != -1);
    }
  }
 
  public void testFriendlyErrorOnNoLocation3ArgMatching() {
    AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
    try {
      pc.matches(getAge, ITestBean.class, (Object[]) null);
      fail();
    }
    catch (IllegalStateException ex) {
      assertTrue(ex.getMessage().indexOf("expression") != -1);
    }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

      ((AspectJExpressionPointcut) pc).getPointcutExpression();
    assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());   
  }
 
  private Pointcut getPointcut(String expression) {
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression(expression);
    return pointcut;
  }
View Full Code Here

Examples of org.springframework.aop.aspectj.AspectJExpressionPointcut

public class AspectJPointcutAdvisorTests extends TestCase {
 
  private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();

  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

    assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
    assertFalse(ajpa.isPerInstance());
  }
 
  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 AbstractAspectJAdvisorFactoryTests.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.