Package org.springframework.aop

Examples of org.springframework.aop.Advisor


        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(advisors[i]);
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) advisor);
  }
View Full Code Here

  public static boolean makeAdvisorChainAspectJCapableIfNecessary(List advisors) {
    // Don't add advisors to an empty list; may indicate that proxying is just not required
    if (!advisors.isEmpty()) {
      boolean foundAspectJAdvice = false;
      for (Iterator it = advisors.iterator(); it.hasNext() && !foundAspectJAdvice; ) {
        Advisor advisor = (Advisor) it.next();
        // Be careful not to get the Advice without a guard, as
        // this might eagerly instantiate a non-singleton AspectJ aspect
        if (isAspectJAdvice(advisor)) {
          foundAspectJAdvice = true;
        }
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 (config.isPreFiltered() || 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

    final List<Advisor> advisors = new LinkedList<Advisor>();
    ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
      public void doWith(Method method) throws IllegalArgumentException {
        // Exclude pointcuts
        if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
          Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
          if (advisor != null) {
            advisors.add(advisor);
          }
        }
      }
    });

    // If it's a per target aspect, emit the dummy instantiating aspect.
    if (!advisors.isEmpty() && lazySingletonAspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
      Advisor instantiationAdvisor = new SyntheticInstantiationAdvisor(lazySingletonAspectInstanceFactory);
      advisors.add(0, instantiationAdvisor);
    }

    // Find introduction fields.
    for (Field field : aspectClass.getDeclaredFields()) {
      Advisor advisor = getDeclareParentsAdvisor(field);
      if (advisor != null) {
        advisors.add(advisor);
      }
    }
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

      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

    final MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
        new LazySingletonAspectInstanceFactoryDecorator(maaif);

    final List<Advisor> advisors = new LinkedList<Advisor>();
    for (Method method : getAdvisorMethods(aspectClass)) {
      Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
      if (advisor != null) {
        advisors.add(advisor);
      }
    }

    // If it's a per target aspect, emit the dummy instantiating aspect.
    if (!advisors.isEmpty() && lazySingletonAspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
      Advisor instantiationAdvisor = new SyntheticInstantiationAdvisor(lazySingletonAspectInstanceFactory);
      advisors.add(0, instantiationAdvisor);
    }

    // Find introduction fields.
    for (Field field : aspectClass.getDeclaredFields()) {
      Advisor advisor = getDeclareParentsAdvisor(field);
      if (advisor != null) {
        advisors.add(advisor);
      }
    }
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.