Package org.springframework.aop

Examples of org.springframework.aop.Advisor


   * @return whether this advice instance is included
   */
  public boolean adviceIncluded(Advice advice) {
    Assert.notNull(advice, "Advice must not be null");
    for (int i = 0; i < this.advisors.size(); i++) {
      Advisor advisor = (Advisor) this.advisors.get(i);
      if (advisor.getAdvice() == advice) {
        return true;
      }
    }
    return false;
  }
View Full Code Here


   */
  public int countAdvicesOfType(Class adviceClass) {
    Assert.notNull(adviceClass, "Advice class must not be null");
    int count = 0;
    for (int i = 0; i < this.advisors.size(); i++) {
      Advisor advisor = (Advisor) this.advisors.get(i);
      if (advisor.getAdvice() != null &&
          adviceClass.isAssignableFrom(advisor.getAdvice().getClass())) {
        count++;
      }
    }
    return count;
  }
View Full Code Here

    copyFrom(other);
    this.targetSource = targetSource;
    this.advisorChainFactory = other.advisorChainFactory;
    this.interfaces = new ArrayList(other.interfaces);
    for (Iterator it = advisors.iterator(); it.hasNext();) {
      Advisor advisor = (Advisor) it.next();
      if (advisor instanceof IntroductionAdvisor) {
        validateIntroductionAdvisor((IntroductionAdvisor) advisor);
      }
      Assert.notNull(advisor, "Advisor must not be null");
      this.advisors.add(advisor);
View Full Code Here

    List interceptorList = new ArrayList(config.getAdvisors().length);
    boolean hasIntroductions = hasMatchingIntroductions(config, targetClass);
    AdvisorAdapterRegistry registry = GlobalAdvisorAdapterRegistry.getInstance();
    Advisor[] advisors = config.getAdvisors();
    for (int i = 0; i < advisors.length; i++) {
      Advisor advisor = advisors[i];
      if (advisor instanceof PointcutAdvisor) {
        // Add it conditionally.
        PointcutAdvisor pointcutAdvisor = (PointcutAdvisor) advisor;
        if (pointcutAdvisor.getPointcut().getClassFilter().matches(targetClass)) {
          MethodInterceptor[] interceptors = registry.getInterceptors(advisor);
View Full Code Here

  /**
   * Determine whether the Advisors contain matching introductions.
   */
  private static boolean hasMatchingIntroductions(Advised config, Class targetClass) {
    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(targetClass)) {
          return true;
        }
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 (candidateAdvisors.isEmpty()) {
      return candidateAdvisors;
    }
    List eligibleAdvisors = new LinkedList();
    for (Iterator it = candidateAdvisors.iterator(); it.hasNext();) {
      Advisor candidate = (Advisor) it.next();
      if (candidate instanceof IntroductionAdvisor && canApply(candidate, clazz)) {
        eligibleAdvisors.add(candidate);
      }
    }
    boolean hasIntroductions = !eligibleAdvisors.isEmpty();
    for (Iterator it = candidateAdvisors.iterator(); it.hasNext();) {
      Advisor candidate = (Advisor) it.next();
      if (candidate instanceof IntroductionAdvisor) {
        // already processed
        continue;
      }
      if (canApply(candidate, clazz, hasIntroductions)) {
View Full Code Here

    this.anyOldPointcut.setExpression("execution(* *(..))");
  }


  public void testSameAspectNoAfterAdvice() {
    Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor1 sorted before advisor2", -1, this.comparator.compare(advisor1, advisor2));

    advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
    advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor2 sorted before advisor1", 1, this.comparator.compare(advisor1, advisor2));
View Full Code Here

    advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor2 sorted before advisor1", 1, this.comparator.compare(advisor1, advisor2));
  }

  public void testSameAspectAfterAdvice() {
    Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor2 sorted before advisor1", 1, this.comparator.compare(advisor1, advisor2));

    advisor1 = createAspectJAfterReturningAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
    advisor2 = createAspectJAfterThrowingAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor1 sorted before advisor2", -1, this.comparator.compare(advisor1, advisor2));
View Full Code Here

    advisor2 = createAspectJAfterThrowingAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor1 sorted before advisor2", -1, this.comparator.compare(advisor1, advisor2));
  }

  public void testSameAspectOneOfEach() {
    Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
    Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
    assertEquals("advisor1 and advisor2 not comparable", 0, this.comparator.compare(advisor1, advisor2));
  }
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.