Package org.springframework.aop.support

Examples of org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor


  public void testOverloadedMethodsWithDifferentAdvice() throws Throwable {
    Overloads target = new Overloads();
    ProxyFactory pc = new ProxyFactory(target);
    NopInterceptor overLoadVoids = new NopInterceptor();
    pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
      public boolean matches(Method m, Class targetClass) {
        return m.getName().equals("overload") && m.getParameterTypes().length == 0;
      }
    });
    NopInterceptor overLoadInts = new NopInterceptor();
    pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
      public boolean matches(Method m, Class targetClass) {
        return m.getName().equals("overload") && m.getParameterTypes().length == 1 &&
          m.getParameterTypes()[0].equals(int.class);
      }
    });
View Full Code Here


    assertFalse(proxyA.equals(proxyB));
  }

  public void testBeforeAdvisorIsInvoked() {
    CountingBeforeAdvice cba = new CountingBeforeAdvice();
    Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
      public boolean matches(Method m, Class targetClass) {
        return m.getParameterTypes().length == 0;
      }
    };
    TestBean target = new TestBean();
View Full Code Here

    assertEquals(newName, tb.getName());
  }

  public void testMultiAdvice() throws Throwable {
    CountingMultiAdvice cca = new CountingMultiAdvice();
    Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
      public boolean matches(Method m, Class targetClass) {
        return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
      }
    };
    TestBean target = new TestBean();
View Full Code Here

      public void afterReturning(Object returnValue, Method m, Object[] args, Object target) throws Throwable {
        sum += ((Integer) returnValue).intValue();
      }
    }
    SummingAfterAdvice aa = new SummingAfterAdvice();
    Advisor matchesInt = new StaticMethodMatcherPointcutAdvisor(aa) {
      public boolean matches(Method m, Class targetClass) {
        return m.getReturnType() == int.class;
      }
    };
    TestBean target = new TestBean();
View Full Code Here


  public void testThrowsAdvisorIsInvoked() throws Throwable {
    // Reacts to ServletException and RemoteException
    ThrowsAdviceInterceptorTests.MyThrowsHandler th = new ThrowsAdviceInterceptorTests.MyThrowsHandler();
    Advisor matchesEchoInvocations = new StaticMethodMatcherPointcutAdvisor(th) {
      public boolean matches(Method m, Class targetClass) {
        return m.getName().startsWith("echo");
      }
    };
View Full Code Here

        clone1.proceed();
        clone2.proceed();
        return mi.proceed();
      }
    };
    StaticMethodMatcherPointcutAdvisor advisor = new StaticMethodMatcherPointcutAdvisor(twoBirthdayInterceptor) {
      public boolean matches(Method m, Class targetClass) {
        return "haveBirthday".equals(m.getName());
      }
    };
    pc.addAdvisor(advisor);
View Full Code Here

        clone1.proceed();
        clone2.proceed();
        return mi.proceed();
      }
    };
    @SuppressWarnings("serial")
    StaticMethodMatcherPointcutAdvisor advisor = new StaticMethodMatcherPointcutAdvisor(twoBirthdayInterceptor) {
      @Override
      public boolean matches(Method m, Class<?> targetClass) {
        return "haveBirthday".equals(m.getName());
      }
    };
View Full Code Here

  @Test
  public void testOverloadedMethodsWithDifferentAdvice() throws Throwable {
    Overloads target = new Overloads();
    ProxyFactory pc = new ProxyFactory(target);
    NopInterceptor overLoadVoids = new NopInterceptor();
    pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
      @Override
      public boolean matches(Method m, Class<?> targetClass) {
        return m.getName().equals("overload") && m.getParameterTypes().length == 0;
      }
    });
    NopInterceptor overLoadInts = new NopInterceptor();
    pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
      @Override
      public boolean matches(Method m, Class<?> targetClass) {
        return m.getName().equals("overload") && m.getParameterTypes().length == 1 &&
          m.getParameterTypes()[0].equals(int.class);
      }
View Full Code Here

  @Test
  public void testBeforeAdvisorIsInvoked() {
    CountingBeforeAdvice cba = new CountingBeforeAdvice();
    @SuppressWarnings("serial")
    Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
      @Override
      public boolean matches(Method m, Class<?> targetClass) {
        return m.getParameterTypes().length == 0;
      }
    };
View Full Code Here

  @Test
  public void testMultiAdvice() throws Throwable {
    CountingMultiAdvice cca = new CountingMultiAdvice();
    @SuppressWarnings("serial")
    Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
      @Override
      public boolean matches(Method m, Class<?> targetClass) {
        return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
      }
    };
View Full Code Here

TOP

Related Classes of org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor

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.