Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.AutowireCandidateQualifier


    // Create the AcrossContextBeanRegistry
    AcrossContextBeanRegistry contextBeanRegistry = new DefaultAcrossContextBeanRegistry( contextInfo );
    providedBeans.put( contextBeanRegistry.getFactoryName(),
                       new PrimarySingletonBean(
                           new DefaultAcrossContextBeanRegistry( contextInfo ),
                           new AutowireCandidateQualifier( Qualifier.class.getName(),
                                                           AcrossContextBeanRegistry.BEAN )
                       ) );

    // Put the context and its info as fixed singletons
    providedBeans.put( AcrossContext.BEAN, new PrimarySingletonBean( context ) );
    providedBeans.put( AcrossContextInfo.BEAN, new PrimarySingletonBean( contextInfo ) );

    // Put the module info as singletons in the context
    for ( AcrossModuleInfo moduleInfo : contextInfo.getConfiguredModules() ) {
      // Create the module instances as primary beans so they do not clash with modules
      // configured as beans in a parent application context
      providedBeans.put( "across.module." + moduleInfo.getName(),
                         new PrimarySingletonBean(
                             moduleInfo.getModule(),
                             new AutowireCandidateQualifier( Module.class.getName(),
                                                             moduleInfo.getName() )
                         )
      );
      providedBeans.put( moduleInfo.getName(),
                         new SingletonBean(
                             moduleInfo,
                             new AutowireCandidateQualifier( Module.class.getName(),
                                                             moduleInfo.getName() )
                         )
      );
      providedBeans.put( "across.moduleSettings." + moduleInfo.getName(),
                         new SingletonBean(
                             moduleInfo.getSettings(),
                             new AutowireCandidateQualifier( Module.class.getName(),
                                                             moduleInfo.getName() )
                         ) );
    }

    context.addApplicationContextConfigurer( new ProvidedBeansConfigurer( providedBeans ),
View Full Code Here


    constructorArgumentValues.addGenericArgumentValue( moduleName );
    constructorArgumentValues.addGenericArgumentValue( originalBeanName );

    setConstructorArgumentValues( constructorArgumentValues );

    addQualifier( new AutowireCandidateQualifier( Module.class.getName(), moduleName ) );
    //addQualifier( new AutowireCandidateQualifier( Context.class.getName(), contextId ) );

    this.originalBeanName = originalBeanName;
    fullyQualifiedBeanName = contextId + "." + moduleName + "@" + originalBeanName;
View Full Code Here

    return preferredBeanName;
  }

  public void setPreferredBeanName( String preferredBeanName ) {
    this.preferredBeanName = preferredBeanName;
    addQualifier( new AutowireCandidateQualifier( Qualifier.class.getName(), preferredBeanName ) );
  }
View Full Code Here

  protected boolean checkQualifier(
      BeanDefinitionHolder bdHolder, Annotation annotation, TypeConverter typeConverter) {

    Class<? extends Annotation> type = annotation.annotationType();
    AbstractBeanDefinition bd = (AbstractBeanDefinition) bdHolder.getBeanDefinition();
    AutowireCandidateQualifier qualifier = bd.getQualifier(type.getName());
    if (qualifier == null) {
      qualifier = bd.getQualifier(ClassUtils.getShortName(type));
    }
    if (qualifier == null) {
      Annotation targetAnnotation = null;
//      if (bd.getResolvedFactoryMethod() != null) {
//        targetAnnotation = bd.getResolvedFactoryMethod().getAnnotation(type);
//      }
      if (targetAnnotation == null) {
        // look for matching annotation on the target class
        Class<?> beanType = null;
        if (bd.getBeanClassName() != null) {
          try {
            beanType = org.springframework.ide.eclipse.core.java.ClassUtils.loadClass(bd.getBeanClassName());
          }
          catch (ClassNotFoundException e) {
          }
        }
        if (beanType != null) {
          targetAnnotation = ClassUtils.getUserClass(beanType).getAnnotation(type);
        }
      }
      if (targetAnnotation != null && targetAnnotation.equals(annotation)) {
        return true;
      }
    }
    Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
    if (attributes.isEmpty() && qualifier == null) {
      // if no attributes, the qualifier must be present
      return false;
    }
    for (Map.Entry<String, Object> entry : attributes.entrySet()) {
      String attributeName = entry.getKey();
      Object expectedValue = entry.getValue();
      Object actualValue = null;
      // check qualifier first
      if (qualifier != null) {
        actualValue = qualifier.getAttribute(attributeName);
      }
      if (actualValue == null) {
        // fall back on bean definition attribute
        actualValue = bd.getAttribute(attributeName);
      }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.AutowireCandidateQualifier

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.