Package org.springframework.aop

Examples of org.springframework.aop.MethodMatcher.matches()


    MethodMatcher mm1 = MethodMatcher.TRUE;
    MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
    MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
    assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
    assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
    // Knock out dynamic part
    intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
    assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
    assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
View Full Code Here


    assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
    // Knock out dynamic part
    intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
    assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
    assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
  }
 
  public void testStaticMethodMatcherUnion() throws Exception {
    MethodMatcher getterMatcher = new StartsWithMatcher("get");
View Full Code Here

    assertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
    // Knock out dynamic part
    intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
    assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
    assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
  }
 
  public void testStaticMethodMatcherUnion() throws Exception {
    MethodMatcher getterMatcher = new StartsWithMatcher("get");
    MethodMatcher setterMatcher = new StartsWithMatcher("set");
View Full Code Here

    MethodMatcher getterMatcher = new StartsWithMatcher("get");
    MethodMatcher setterMatcher = new StartsWithMatcher("set");
    MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
   
    assertFalse("Union is a static matcher", union.isRuntime());
    assertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.class));
    assertFalse("Didn't matched absquatulate method", union.matches(IOTHER_ABSQUATULATE, TestBean.class));

  }
View Full Code Here

    MethodMatcher setterMatcher = new StartsWithMatcher("set");
    MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
   
    assertFalse("Union is a static matcher", union.isRuntime());
    assertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.class));
    assertFalse("Didn't matched absquatulate method", union.matches(IOTHER_ABSQUATULATE, TestBean.class));

  }

View Full Code Here

    MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
   
    assertFalse("Union is a static matcher", union.isRuntime());
    assertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.class));
    assertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.class));
    assertFalse("Didn't matched absquatulate method", union.matches(IOTHER_ABSQUATULATE, TestBean.class));

  }


  public static class StartsWithMatcher extends StaticMethodMatcher {
View Full Code Here

        final Pointcut pointcut = (Pointcut) applicationContext.getBean(pointcutBeanName);
        final MethodMatcher methodMatcher = pointcut.getMethodMatcher();
        for(final Class clazz : classes){
                for(final Method method: clazz.getDeclaredMethods()){
                    if(Modifier.isPublic(method.getModifiers())){
                        if(methodMatcher.matches(method, clazz,method.getParameterTypes())){
                            if(LOGGER.isDebugEnabled()){
                                LOGGER.debug("method matches pointcut : "+method);
                            }
                            MethodInvocationStats emptyMethodInvocationStats = new MethodInvocationStats();
                            emptyMethodInvocationStats.setHits(new AtomicLong(-1));
View Full Code Here

    for (Class<?> clazz : classes) {
      Method[] methods = clazz.getMethods();
      for (Method method : methods) {
        if ((introductionAwareMethodMatcher != null &&
            introductionAwareMethodMatcher.matches(method, targetClass, hasIntroductions)) ||
            methodMatcher.matches(method, targetClass)) {
          return true;
        }
      }
    }
View Full Code Here

      return true;
    }
    if (pointcut.getClassFilter().matches(targetClass)) {
      // Only check if it gets past first hurdle.
      MethodMatcher mm = pointcut.getMethodMatcher();
      if (mm.matches(method, targetClass)) {
        // We may need additional runtime (argument) check.
        return (!mm.isRuntime() || mm.matches(method, targetClass, args));
      }
    }
    return false;
View Full Code Here

    if (pointcut.getClassFilter().matches(targetClass)) {
      // Only check if it gets past first hurdle.
      MethodMatcher mm = pointcut.getMethodMatcher();
      if (mm.matches(method, targetClass)) {
        // We may need additional runtime (argument) check.
        return (!mm.isRuntime() || mm.matches(method, targetClass, args));
      }
    }
    return false;
  }
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.