Examples of AnnotationMetadata


Examples of org.springframework.core.type.AnnotationMetadata

      boolean classValuesAsString) throws IOException {

    List<Map<String, Object>> allAttribs = new ArrayList<Map<String, Object>>();

    MetadataReader reader = this.metadataReaderFactory.getMetadataReader(annotatedClassName);
    AnnotationMetadata metadata = reader.getAnnotationMetadata();
    String targetAnnotationType = targetAnnotation.getName();

    for (String annotationType : metadata.getAnnotationTypes()) {
      if (annotationType.equals(targetAnnotationType)) {
        continue;
      }
      MetadataReader metaReader = this.metadataReaderFactory.getMetadataReader(annotationType);
      Map<String, Object> targetAttribs =
        metaReader.getAnnotationMetadata().getAnnotationAttributes(targetAnnotationType, classValuesAsString);
      if (targetAttribs != null) {
        allAttribs.add(targetAttribs);
      }
    }

    Map<String, Object> localAttribs =
      metadata.getAnnotationAttributes(targetAnnotationType, classValuesAsString);
    if (localAttribs != null) {
      allAttribs.add(localAttribs);
    }

    return allAttribs;
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

    if (checkForCircularImports && this.importStack.contains(configClass)) {
      this.problemReporter.error(new CircularImportProblem(configClass, this.importStack, configClass.getMetadata()));
    }
    else {
      this.importStack.push(configClass);
      AnnotationMetadata importingClassMetadata = configClass.getMetadata();
      for (String candidate : classesToImport) {
        MetadataReader reader = this.metadataReaderFactory.getMetadataReader(candidate);
        if (new AssignableTypeFilter(ImportSelector.class).match(reader, metadataReaderFactory)) {
          // the candidate class is an ImportSelector -> delegate to it to determine imports
          try {
            ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class);
            processImport(configClass, selector.selectImports(importingClassMetadata), false);
          } catch (ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
          }
        }
        else if (new AssignableTypeFilter(ImportBeanDefinitionRegistrar.class).match(reader, metadataReaderFactory)) {
          // the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions
          try {
            ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClass(Class.forName(candidate), ImportBeanDefinitionRegistrar.class);
            registrar.registerBeanDefinitions(importingClassMetadata, registry);
          } catch (ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
          }
        }
        else {
          // the candidate class not an ImportSelector or ImportBeanDefinitionRegistrar -> process it as a @Configuration class
          this.importStack.registerImport(importingClassMetadata.getClassName(), candidate);
          processConfigurationClass(new ConfigurationClass(reader, null));
        }
      }
      this.importStack.pop();
    }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

      }
    }
    else {
      try {
        MetadataReader reader = this.metadataReaderFactory.getMetadataReader(className);
        AnnotationMetadata metadata = reader.getAnnotationMetadata();
        this.problemReporter.error(
            new InvalidConfigurationImportProblem(className, reader.getResource(), metadata));
      }
      catch (IOException ex) {
        throw new IllegalStateException("Could not create MetadataReader for class " + className);
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

   * @param beanDef the bean definition to check
   * @param metadataReaderFactory the current factory in use by the caller
   * @return whether the candidate qualifies as (any kind of) configuration class
   */
  public static boolean checkConfigurationClassCandidate(BeanDefinition beanDef, MetadataReaderFactory metadataReaderFactory) {
    AnnotationMetadata metadata = null;

    // Check already loaded Class if present...
    // since we possibly can't even load the class file for this Class.
    if (beanDef instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) beanDef).hasBeanClass()) {
      metadata = new StandardAnnotationMetadata(((AbstractBeanDefinition) beanDef).getBeanClass());
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

    registerBean(annotatedClass, null, qualifiers);
  }

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();

    if (ProfileHelper.isProfileAnnotationPresent(metadata)) {
      if (!this.environment.acceptsProfiles(ProfileHelper.getCandidateProfiles(metadata))) {
        return;
      }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

   * @param beanDef the bean definition to check
   * @param metadataReaderFactory the current factory in use by the caller
   * @return whether the candidate qualifies as (any kind of) configuration class
   */
  public static boolean checkConfigurationClassCandidate(BeanDefinition beanDef, MetadataReaderFactory metadataReaderFactory) {
    AnnotationMetadata metadata = null;

    // Check already loaded Class if present...
    // since we possibly can't even load the class file for this Class.
    if (beanDef instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) beanDef).hasBeanClass()) {
      Class<?> beanClass = ((AbstractBeanDefinition) beanDef).getBeanClass();
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

    registry.registerBeanDefinition(beanName, definition);
    return new BeanDefinitionHolder(definition, beanName);
  }

  static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd) {
    AnnotationMetadata metadata = abd.getMetadata();
    if (metadata.isAnnotated(Primary.class.getName())) {
      abd.setPrimary(true);
    }
    if (metadata.isAnnotated(Lazy.class.getName())) {
      abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value"));
    }
    if (metadata.isAnnotated(DependsOn.class.getName())) {
      abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value"));
    }
    if (abd instanceof AbstractBeanDefinition) {
      if (metadata.isAnnotated(Role.class.getName())) {
        Integer role = attributesFor(metadata, Role.class).getNumber("value");
        ((AbstractBeanDefinition)abd).setRole(role);
      }
    }
  }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

      ConfigurationClass configClass, AnnotationMetadata metadata) throws IOException {

    // recursively process any member (nested) classes first
    for (String memberClassName : metadata.getMemberClassNames()) {
      MetadataReader reader = this.metadataReaderFactory.getMetadataReader(memberClassName);
      AnnotationMetadata memberClassMetadata = reader.getAnnotationMetadata();
      if (ConfigurationClassUtils.isConfigurationCandidate(memberClassMetadata)) {
        processConfigurationClass(new ConfigurationClass(reader, true));
      }
    }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

   * @throws IOException if there is any problem reading metadata from the named class
   */
  private Set<String> getImports(String className, Set<String> imports,
      Set<String> visited) throws IOException {
    if (visited.add(className)) {
      AnnotationMetadata metadata = metadataReaderFactory.getMetadataReader(className).getAnnotationMetadata();
      for (String annotationType : metadata.getAnnotationTypes()) {
        imports = getImports(annotationType, imports, visited);
      }
      Map<String, Object> attributes = metadata.getAnnotationAttributes(Import.class.getName(), true);
      if (attributes != null) {
        String[] value = (String[]) attributes.get("value");
        if (value != null && value.length > 0) {
          imports = (imports == null ? new LinkedHashSet<String>() : imports);
          imports.addAll(Arrays.asList(value));
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

    if (checkForCircularImports && this.importStack.contains(configClass)) {
      this.problemReporter.error(new CircularImportProblem(configClass, this.importStack, configClass.getMetadata()));
    }
    else {
      this.importStack.push(configClass);
      AnnotationMetadata importingClassMetadata = configClass.getMetadata();
      for (String candidate : classesToImport) {
        MetadataReader reader = this.metadataReaderFactory.getMetadataReader(candidate);
        if (new AssignableTypeFilter(ImportSelector.class).match(reader, this.metadataReaderFactory)) {
          // the candidate class is an ImportSelector -> delegate to it to determine imports
          try {
            ImportSelector selector = BeanUtils.instantiateClass(
                this.resourceLoader.getClassLoader().loadClass(candidate), ImportSelector.class);
            processImport(configClass, selector.selectImports(importingClassMetadata), false);
          }
          catch (ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
          }
        }
        else if (new AssignableTypeFilter(ImportBeanDefinitionRegistrar.class).match(reader, metadataReaderFactory)) {
          // the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions
          try {
            ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClass(
                this.resourceLoader.getClassLoader().loadClass(candidate), ImportBeanDefinitionRegistrar.class);
            invokeAwareMethods(registrar);
            registrar.registerBeanDefinitions(importingClassMetadata, registry);
          }
          catch (ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
          }
        }
        else {
          // the candidate class not an ImportSelector or ImportBeanDefinitionRegistrar -> process it as a @Configuration class
          this.importStack.registerImport(importingClassMetadata.getClassName(), candidate);
          processConfigurationClass(new ConfigurationClass(reader, true));
        }
      }
      this.importStack.pop();
    }
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.