Package org.springframework.aop

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


    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));
  }

  @Test
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));
  }

  @Test
  public void testUnionEquals() {
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));
  }

  @Test
  public void testUnionEquals() {
    MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
View Full Code Here

    // not currently testable in a reliable fashion
    //assertDoesNotMatchStringClass(classFilter);

    assertFalse("Should not be a runtime match", methodMatcher.isRuntime());
    assertMatchesGetAge(methodMatcher);
    assertFalse("Expression should match setAge() method", methodMatcher.matches(setAge, TestBean.class));
  }

  @Test
  public void testMatchWithTypePattern() throws Exception {
    String expression = "execution(* *..TestBean.*Age(..))";
 
View Full Code Here

    // not currently testable in a reliable fashion
    //assertDoesNotMatchStringClass(classFilter);

    assertFalse("Should not be a runtime match", methodMatcher.isRuntime());
    assertMatchesGetAge(methodMatcher);
    assertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.class));
  }


  @Test
  public void testThis() throws SecurityException, NoSuchMethodException{
View Full Code Here

    // not currently testable in a reliable fashion
    //assertDoesNotMatchStringClass(classFilter);

    assertTrue("Should match with setSomeNumber with Double input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
    assertFalse("Should not match setSomeNumber with Integer input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
    assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
    assertTrue("Should be a runtime match", methodMatcher.isRuntime());
  }
View Full Code Here

    //assertDoesNotMatchStringClass(classFilter);

    assertTrue("Should match with setSomeNumber with Double input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
    assertFalse("Should not match setSomeNumber with Integer input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
    assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
    assertTrue("Should be a runtime match", methodMatcher.isRuntime());
  }

  @Test
View Full Code Here

    assertTrue("Should match with setSomeNumber with Double input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
    assertFalse("Should not match setSomeNumber with Integer input",
        methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
    assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
    assertTrue("Should be a runtime match", methodMatcher.isRuntime());
  }

  @Test
  public void testSimpleAdvice() {
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

        final MethodMatcher methodMatcher = pointcut.getMethodMatcher();
        final List<Class> pojoClasses = adviceNotifier.getClassList();
        for(final Class pojoClass: pojoClasses){
                for(final Method method: pojoClass.getDeclaredMethods()){
                    if(Modifier.isPublic(method.getModifiers())){
                        if(methodMatcher.matches(method,pojoClass,method.getParameterTypes())){
                            if(LOGGER.isDebugEnabled()){
                                LOGGER.debug("method matches pointcut : "+method);
                            }
                            MethodInvocationStats emptyMethodInvocationStats = new MethodInvocationStats();
                            emptyMethodInvocationStats.setHits(new AtomicLong(-1));
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.