Examples of AnnotationAttributes


Examples of org.springframework.core.annotation.AnnotationAttributes

  public AnnotationAttributesReadingVisitor(
      String annotationType, Map<String, AnnotationAttributes> attributesMap,
      Map<String, Set<String>> metaAnnotationMap, ClassLoader classLoader) {

    super(annotationType, new AnnotationAttributes(), classLoader);
    this.annotationType = annotationType;
    this.attributesMap = attributesMap;
    this.metaAnnotationMap = metaAnnotationMap;
  }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  }

  public AnnotationAttributes getAnnotationAttributes(
      String annotationType, boolean classValuesAsString, boolean nestedAttributesAsMap) {

    AnnotationAttributes raw = this.attributeMap.get(annotationType);
    return convertClassValues(raw, classValuesAsString, nestedAttributesAsMap);
  }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

      AnnotationAttributes original, boolean classValuesAsString, boolean nestedAttributesAsMap) {

    if (original == null) {
      return null;
    }
    AnnotationAttributes result = new AnnotationAttributes(original.size());
    for (Map.Entry<String, Object> entry : original.entrySet()) {
      try {
        Object value = entry.getValue();
        if (value instanceof AnnotationAttributes) {
          value = convertClassValues((AnnotationAttributes)value, classValuesAsString, nestedAttributesAsMap);
        }
        else if (value instanceof AnnotationAttributes[]) {
          AnnotationAttributes[] values = (AnnotationAttributes[])value;
          for (int i = 0; i < values.length; i++) {
            values[i] = convertClassValues(values[i], classValuesAsString, nestedAttributesAsMap);
          }
        }
        else if (value instanceof Type) {
          value = (classValuesAsString ? ((Type) value).getClassName() :
              this.classLoader.loadClass(((Type) value).getClassName()));
        }
        else if (value instanceof Type[]) {
          Type[] array = (Type[]) value;
          Object[] convArray = (classValuesAsString ? new String[array.length] : new Class[array.length]);
          for (int i = 0; i < array.length; i++) {
            convArray[i] = (classValuesAsString ? array[i].getClassName() :
                this.classLoader.loadClass(array[i].getClassName()));
          }
          value = convArray;
        }
        else if (classValuesAsString) {
          if (value instanceof Class) {
            value = ((Class<?>) value).getName();
          }
          else if (value instanceof Class[]) {
            Class<?>[] clazzArray = (Class[]) value;
            String[] newValue = new String[clazzArray.length];
            for (int i = 0; i < clazzArray.length; i++) {
              newValue[i] = clazzArray[i].getName();
            }
            value = newValue;
          }
        }
        result.put(entry.getKey(), value);
      }
      catch (Exception ex) {
        // Class not found - can't resolve class reference in annotation attribute.
      }
    }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  public void registerBeanDefinitions(
      AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

    AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);

    AnnotationAttributes enableAJAutoProxy =
        attributesFor(importingClassMetadata, EnableAspectJAutoProxy.class);
    if (enableAJAutoProxy.getBoolean("proxyTargetClass")) {
      AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
    }
  }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
      AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
      AnnotationAttributes attributes =
          attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
      if (attributes != null) {
        metadata.setScopeName(attributes.getString("value"));
        ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
        if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
          proxyMode = this.defaultProxyMode;
        }
        metadata.setScopedProxyMode(proxyMode);
      }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
      AnnotationAttributes attributes = MetadataUtils.attributesFor(amd, type);
      if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
        String value = (String) attributes.get("value");
        if (StringUtils.hasLength(value)) {
          if (beanName != null && !value.equals(beanName)) {
            throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                "component names: '" + beanName + "' versus '" + value + "'");
          }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();
    if (metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        return;
      }
    }
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
    abd.setScope(scopeMetadata.getScopeName());
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

      if (tf.match(metadataReader, this.metadataReaderFactory)) {
        AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
        if (!metadata.isAnnotated(Profile.class.getName())) {
          return true;
        }
        AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
        return this.environment.acceptsProfiles(profile.getStringArray("value"));
      }
    }
    return false;
  }
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  }

  protected void processConfigurationClass(ConfigurationClass configClass) throws IOException {
    AnnotationMetadata metadata = configClass.getMetadata();
    if (this.environment != null && metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        return;
      }
    }

    // recursively process the configuration class and its superclass hierarchy
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

        processConfigurationClass(new ConfigurationClass(reader, true));
      }
    }

    // process any @PropertySource annotations
    AnnotationAttributes propertySource =
        attributesFor(metadata, org.springframework.context.annotation.PropertySource.class);
    if (propertySource != null) {
      String name = propertySource.getString("name");
      String[] locations = propertySource.getStringArray("value");
      int nLocations = locations.length;
      if (nLocations == 0) {
        throw new IllegalArgumentException("At least one @PropertySource(value) location is required");
      }
      for (int i = 0; i < nLocations; i++) {
        locations[i] = this.environment.resolveRequiredPlaceholders(locations[i]);
      }
      ClassLoader classLoader = this.resourceLoader.getClassLoader();
      if (!StringUtils.hasText(name)) {
        for (String location : locations) {
          this.propertySources.push(new ResourcePropertySource(location, classLoader));
        }
      }
      else {
        if (nLocations == 1) {
          this.propertySources.push(new ResourcePropertySource(name, locations[0], classLoader));
        }
        else {
          CompositePropertySource ps = new CompositePropertySource(name);
          for (String location : locations) {
            ps.addPropertySource(new ResourcePropertySource(location, classLoader));
          }
          this.propertySources.push(ps);
        }
      }
    }

    // process any @ComponentScan annotions
    AnnotationAttributes componentScan = attributesFor(metadata, ComponentScan.class);
    if (componentScan != null) {
      // the config class is annotated with @ComponentScan -> perform the scan immediately
      Set<BeanDefinitionHolder> scannedBeanDefinitions =
          this.componentScanParser.parse(componentScan, metadata.getClassName());

      // check the set of scanned definitions for any further config classes and parse recursively if necessary
      for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
        if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
          this.parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
        }
      }
    }

    // process any @Import annotations
    Set<String> imports = getImports(metadata.getClassName(), null, new HashSet<String>());
    if (imports != null && !imports.isEmpty()) {
      processImport(configClass, imports.toArray(new String[imports.size()]), true);
    }

    // process any @ImportResource annotations
    if (metadata.isAnnotated(ImportResource.class.getName())) {
      AnnotationAttributes importResource = attributesFor(metadata, ImportResource.class);
      String[] resources = importResource.getStringArray("value");
      Class<? extends BeanDefinitionReader> readerClass = importResource.getClass("reader");
      for (String resource : resources) {
        configClass.addImportedResource(resource, readerClass);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.