Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.NoUniqueBeanDefinitionException


                if (basePackages != null) {
                    final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
                        ClasspathScanner.findClasses(basePackages, Path.class, Provider.class);
                   
                    if (classes.get(Path.class).size() > 1) {
                        throw new NoUniqueBeanDefinitionException(Path.class, classes.get(Path.class).size(),
                            "More than one service class (@Path) has been discovered");
                    } else {                     
                        for (final Class< ? > providerClass: classes.get(Provider.class)) {
                            setProvider(ctx.getAutowireCapableBeanFactory().createBean(providerClass));
                        }
View Full Code Here


                    @SuppressWarnings("unchecked")
                    final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
                        ClasspathScanner.findClasses(basePackages, Path.class, Provider.class);
                   
                    if (classes.get(Path.class).size() > 1) {
                        throw new NoUniqueBeanDefinitionException(Path.class, classes.get(Path.class).size(),
                            "More than one service class (@Path) has been discovered");
                    } else {                     
                        for (final Class< ? > providerClass: classes.get(Provider.class)) {
                            setProvider(ctx.getAutowireCapableBeanFactory().createBean(providerClass));
                        }
View Full Code Here

                    @SuppressWarnings("unchecked")
                    final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
                        ClasspathScanner.findClasses(basePackages, Path.class, Provider.class);
                   
                    if (classes.get(Path.class).size() > 1) {
                        throw new NoUniqueBeanDefinitionException(Path.class, classes.get(Path.class).size(),
                            "More than one service class (@Path) has been discovered");
                    } else {                     
                        for (final Class< ? > providerClass: classes.get(Provider.class)) {
                            setProvider(ctx.getAutowireCapableBeanFactory().createBean(providerClass));
                        }
View Full Code Here

      }
      String priorityCandidate = determineHighestPriorityCandidate(candidates, requiredType);
      if (priorityCandidate != null) {
        return getBean(priorityCandidate, requiredType, args);
      }
      throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
    }
    else if (getParentBeanFactory() != null) {
      return getParentBeanFactory().getBean(requiredType, args);
    }
    else {
View Full Code Here

        return null;
      }
      if (matchingBeans.size() > 1) {
        String primaryBeanName = determineAutowireCandidate(matchingBeans, descriptor);
        if (primaryBeanName == null) {
          throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
        }
        if (autowiredBeanNames != null) {
          autowiredBeanNames.add(primaryBeanName);
        }
        return matchingBeans.get(primaryBeanName);
View Full Code Here

      if (isPrimary(candidateBeanName, beanInstance)) {
        if (primaryBeanName != null) {
          boolean candidateLocal = containsBeanDefinition(candidateBeanName);
          boolean primaryLocal = containsBeanDefinition(primaryBeanName);
          if (candidateLocal && primaryLocal) {
            throw new NoUniqueBeanDefinitionException(requiredType, candidateBeans.size(),
                "more than one 'primary' bean found among candidates: " + candidateBeans.keySet());
          }
          else if (candidateLocal) {
            primaryBeanName = candidateBeanName;
          }
View Full Code Here

      Object beanInstance = entry.getValue();
      Integer candidatePriority = getPriority(beanInstance);
      if (candidatePriority != null) {
        if (highestPriorityBeanName != null) {
          if (candidatePriority.equals(highestPriority)) {
            throw new NoUniqueBeanDefinitionException(requiredType, candidateBeans.size(),
                "Multiple beans found with the same priority ('" + highestPriority + "') " +
                    "among candidates: " + candidateBeans.keySet());
          }
          else if (candidatePriority < highestPriority) {
            highestPriorityBeanName = candidateBeanName;
View Full Code Here

    String[] beanNames = getBeanNamesForType(requiredType);
    if (beanNames.length == 1) {
      return getBean(beanNames[0], requiredType);
    }
    else if (beanNames.length > 1) {
      throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
    }
    else {
      throw new NoSuchBeanDefinitionException(requiredType);
    }
  }
View Full Code Here

        ((ConfigurableBeanFactory) this.beanFactory).registerDependentBean(unitName, requestingBeanName);
      }
      return emf;
    }
    else if (beanNames.length > 1) {
      throw new NoUniqueBeanDefinitionException(EntityManagerFactory.class, beanNames);
    }
    else {
      throw new NoSuchBeanDefinitionException(EntityManagerFactory.class);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.NoUniqueBeanDefinitionException

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.