Package org.springframework.aop

Examples of org.springframework.aop.ClassFilter


*/
public class MyPointcut implements Pointcut {

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


        return true;
      }
      if (!super.equals(other)) {
        return false;
      }
      ClassFilter otherCf1 = ClassFilter.TRUE;
      ClassFilter otherCf2 = ClassFilter.TRUE;
      if (other instanceof ClassFilterAwareUnionMethodMatcher) {
        ClassFilterAwareUnionMethodMatcher cfa = (ClassFilterAwareUnionMethodMatcher) other;
        otherCf1 = cfa.cf1;
        otherCf2 = cfa.cf2;
      }
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() {
      @Override
      public boolean matches(Class<?> clazz) {
        return !(introducedInterface.isAssignableFrom(clazz));
      }
    };
View Full Code Here

  @Test
  public void testMatchExplicit() {
    String expression = "execution(int org.springframework.tests.sample.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

  @Test
  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

  @Test
  public void testMatchWithArgs() throws Exception {
    String expression = "execution(void org.springframework.tests.sample.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

  @Test
  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

    super.setPatterns(patterns);
  }

  @Override
  public ClassFilter getClassFilter() {
    final ClassFilter filter = super.getClassFilter();
    return new ClassFilter() {
      public boolean matches(Class clazz) {
        int modifier = clazz.getModifiers();
        if (Modifier.isFinal(modifier)) {
          return false;
        }
        String clazzName = clazz.getName();
        if (beenFilted(clazzName)) {
          return false;
        } else {
          return filter.matches(clazz);
        }
      }
    };
  }
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.