Package org.springframework.aop

Examples of org.springframework.aop.ClassFilter


    public boolean matches(Method method, Class cls) {
        return ("foo".equals(method.getName()));
    }

    public ClassFilter getClassFilter() {
        return new ClassFilter() {
            public boolean matches(Class cls) {
                return (cls == BeanOne.class);
            }
        };
View Full Code Here


        return (x != 100);
    }

    public ClassFilter getClassFilter() {
        return new ClassFilter() {

            public boolean matches(Class cls) {
                return (cls == SampleBean.class);
            }
        };
View Full Code Here

   * @param implementationClass implementation class
   * @param advice delegation advice
   */
  private DeclareParentsAdvisor(Class interfaceType, String typePattern, Class implementationClass, Advice advice) {
    this.introducedInterface = interfaceType;
    ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);

    // Excludes methods implemented.
    ClassFilter exclusion = new ClassFilter() {
      public boolean matches(Class clazz) {
        return !(introducedInterface.isAssignableFrom(clazz));
      }
    };

View Full Code Here

   * @param typePattern type pattern the introduction is restricted to
   * @param defaultImpl default implementation class
   */
  public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) {
    this.introducedInterface = interfaceType;
    ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);

    // Excludes methods implemented.
    ClassFilter exclusion = new ClassFilter() {
      public boolean matches(Class clazz) {
        return !(introducedInterface.isAssignableFrom(clazz));
      }
    };

View Full Code Here

 
  public void testMatchExplicit() {
    String expression = "execution(int org.springframework.beans.TestBean.getAge())";

    Pointcut pointcut = getPointcut(expression);
    ClassFilter classFilter = pointcut.getClassFilter();
    MethodMatcher methodMatcher = pointcut.getMethodMatcher();

    assertMatchesTestBeanClass(classFilter);

    // not currently testable in a reliable fashion
View Full Code Here

  public void testMatchWithTypePattern() throws Exception {
    String expression = "execution(* *..TestBean.*Age(..))";

    Pointcut pointcut = getPointcut(expression);
    ClassFilter classFilter = pointcut.getClassFilter();
    MethodMatcher methodMatcher = pointcut.getMethodMatcher();

    assertMatchesTestBeanClass(classFilter);

    // not currently testable in a reliable fashion
View Full Code Here

 
  public void testMatchWithArgs() throws Exception {
    String expression = "execution(void org.springframework.beans.TestBean.setSomeNumber(Number)) && args(Double)";

    Pointcut pointcut = getPointcut(expression);
    ClassFilter classFilter = pointcut.getClassFilter();
    MethodMatcher methodMatcher = pointcut.getMethodMatcher();

    assertMatchesTestBeanClass(classFilter);

    // not currently testable in a reliable fashion
View Full Code Here

  public void testUnion() {
    assertTrue(exceptionFilter.matches(RuntimeException.class));
    assertFalse(exceptionFilter.matches(TestBean.class));
    assertFalse(itbFilter.matches(Exception.class));
    assertTrue(itbFilter.matches(TestBean.class));
    ClassFilter union = ClassFilters.union(exceptionFilter, itbFilter);
    assertTrue(union.matches(RuntimeException.class));
    assertTrue(union.matches(TestBean.class));
  }
View Full Code Here

  }
 
  public void testIntersection() {
    assertTrue(exceptionFilter.matches(RuntimeException.class));
    assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class));
    ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter);
    assertFalse(intersection.matches(RuntimeException.class));
    assertFalse(intersection.matches(TestBean.class));
    assertTrue(intersection.matches(NestedRuntimeException.class));
  }
View Full Code Here

  public void testFilterByClass() throws NoSuchMethodException {
    ComposablePointcut pc = new ComposablePointcut();
 
    assertTrue(pc.getClassFilter().matches(Object.class));
   
    ClassFilter cf = new RootClassFilter(Exception.class);
    pc.intersection(cf);
    assertFalse(pc.getClassFilter().matches(Object.class));
    assertTrue(pc.getClassFilter().matches(Exception.class));
    pc.intersection(new RootClassFilter(NestedRuntimeException.class));
    assertFalse(pc.getClassFilter().matches(Exception.class));
View Full Code Here

TOP

Related Classes of org.springframework.aop.ClassFilter

Copyright © 2018 www.massapicom. 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.