Package org.springframework.aop

Examples of org.springframework.aop.Advisor


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


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

    }
  }

  private SimpleBeforeAdviceImpl getAdviceImpl(ITestBean tb) {
    Advised advised = (Advised) tb;
    Advisor advisor = advised.getAdvisors()[0];
    return (SimpleBeforeAdviceImpl) advisor.getAdvice();
  }
View Full Code Here

        if (this.beanFactory == null) {
          throw new IllegalStateException("No BeanFactory available anymore (probably due to serialization) " +
              "- cannot resolve prototype advisor '" + pa.getBeanName() + "'");
        }
        Object bean = this.beanFactory.getBean(pa.getBeanName());
        Advisor refreshedAdvisor = namedBeanToAdvisor(bean);
        freshAdvisors.add(refreshedAdvisor);
      }
      else {
        // Add the shared instance.
        freshAdvisors.add(advisor);
View Full Code Here

   * bean factory
   */
  private void addAdvisorOnChainCreation(Object next, String name) {
    // We need to convert to an Advisor if necessary so that our source reference
    // matches what we find from superclass interceptors.
    Advisor advisor = namedBeanToAdvisor(next);
    if (logger.isTraceEnabled()) {
      logger.trace("Adding advisor with name '" + name + "'");
    }
    addAdvisor(advisor);
  }
View Full Code Here

      this.comparator = comparator;
    }

    @Override
    public int compareTo(Object obj) {
      Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor;
      return this.comparator.compare(this.advisor, otherAdvisor);
    }
View Full Code Here

      Advisor[] thatAdvisors = otherAdvised.getAdvisors();
      if (thisAdvisors.length != thatAdvisors.length) {
        return false;
      }
      for (int i = 0; i < thisAdvisors.length; i++) {
        Advisor thisAdvisor = thisAdvisors[i];
        Advisor thatAdvisor = thatAdvisors[i];
        if (!equalsAdviceClasses(thisAdvisor, thatAdvisor)) {
          return false;
        }
        if (!equalsPointcuts(thisAdvisor, thatAdvisor)) {
          return false;
View Full Code Here

    if (index < 0 || index > this.advisors.size() - 1) {
      throw new AopConfigException("Advisor index " + index + " is out of bounds: " +
          "This configuration only has " + this.advisors.size() + " advisors.");
    }

    Advisor advisor = this.advisors.get(index);
    if (advisor instanceof IntroductionAdvisor) {
      IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
      // We need to remove introduction interfaces.
      for (int j = 0; j < ia.getInterfaces().length; j++) {
        removeInterface(ia.getInterfaces()[j]);
View Full Code Here

  @Override
  public int indexOf(Advice advice) {
    Assert.notNull(advice, "Advice must not be null");
    for (int i = 0; i < this.advisors.size(); i++) {
      Advisor advisor = this.advisors.get(i);
      if (advisor.getAdvice() == advice) {
        return i;
      }
    }
    return -1;
  }
View Full Code Here

  /**
   * Determine whether the Advisors contain matching introductions.
   */
  private static boolean hasMatchingIntroductions(Advised config, Class<?> actualClass) {
    for (int i = 0; i < config.getAdvisors().length; i++) {
      Advisor advisor = config.getAdvisors()[i];
      if (advisor instanceof IntroductionAdvisor) {
        IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
        if (ia.getClassFilter().matches(actualClass)) {
          return true;
        }
View Full Code Here

TOP

Related Classes of org.springframework.aop.Advisor

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.