Java 类org.springframework.core.annotation.AnnotationAttributes 实例源码

项目:Your-Microservice    文件:YourMicroserviceBeanConfiguration.java   
/**
 * selectImports
 * <p>
 * Provides a configuration list of additional Import which should be performed to
 * implement the applicable configuration.
 *
 * @param importingClassMetadata Annotations Metadata to use to construct Imports.
 * @return String Array of Configuration Imports.
 */
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes =
            AnnotationAttributes.fromMap(
                    importingClassMetadata.getAnnotationAttributes(EnableYourMicroservice.class.getName(), false));
    String environmentType = attributes.getString("environmentType");
    LOGGER.info("Using specified EnvironmentType:[{}]", environmentType);
    /**
     *  Create our necessary Imports.
     */
    return new String[]{
            YourMicroserviceEnvironmentConfiguration.class.getName()

            // Add Security Import as Applicable ...
    };

}
项目:spring-data-snowdrop    文件:JpaWithSnowdropRegistrar.java   
private BeanDefinition buildPostProcessorDefinition(AnnotationMetadata importMetadata, AnnotationAttributes attributes) {
  SnowdropRepositoryConfigExtension extension = new SnowdropRepositoryConfigExtension();
  BeanDefinitionBuilder builder = BeanDefinitionBuilder
          .rootBeanDefinition(JpaRepositoryFactoryBeanSnowdropPostProcessor.class);

  builder.getRawBeanDefinition().setSource(importMetadata);

  builder.addPropertyValue("queryLookupStrategyKey", attributes.get(QUERY_LOOKUP_STRATEGY));

  NamedQueriesBeanDefinitionBuilder definitionBuilder = new NamedQueriesBeanDefinitionBuilder(
          extension.getDefaultNamedQueryLocation());

  String namedQueriesLocation = attributes.getString(NAMED_QUERIES_LOCATION);
  if (StringUtils.hasText(namedQueriesLocation)) {
    definitionBuilder.setLocations(namedQueriesLocation);
  }
  builder.addPropertyValue("namedQueriesLocation", definitionBuilder.build(importMetadata));

  return builder.getBeanDefinition();
}
项目:lams    文件:AnnotationScopeMetadataResolver.java   
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        AnnotationAttributes attributes = AnnotationConfigUtils.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);
        }
    }
    return metadata;
}
项目:lams    文件:AnnotationBeanNameGenerator.java   
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
        AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
        if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
            Object value = attributes.get("value");
            if (value instanceof String) {
                String strVal = (String) value;
                if (StringUtils.hasLength(strVal)) {
                    if (beanName != null && !strVal.equals(beanName)) {
                        throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                                "component names: '" + beanName + "' versus '" + strVal + "'");
                    }
                    beanName = strVal;
                }
            }
        }
    }
    return beanName;
}
项目:spring-backend-boilerplate    文件:EnableMenuImportSelector.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
    AnnotationAttributes enableMenu = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableMenu.class
                                                                                                            .getName(),
                                                                                                    false));

    if (enableMenu != null) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMenuPlugin.class);
        AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();

        MutablePropertyValues mutablePropertyValues = new MutablePropertyValues();
        mutablePropertyValues.add("extensionPointId", enableMenu.getString("extensionPointId"));
        mutablePropertyValues.add("pluginId", enableMenu.getString("pluginId"));
        mutablePropertyValues.add("menu", toMenu(enableMenu.getAnnotationArray("menu")));
        beanDefinition.setPropertyValues(mutablePropertyValues);

        registry.registerBeanDefinition("menuPlugin:" + enableMenu.getString("pluginId"), beanDefinition);
    }
}
项目:spring-backend-boilerplate    文件:EnableMenuImportSelector.java   
private Map<String,Object> toMetadata(AnnotationAttributes[] metadatas) {
    if (metadatas == null) {
        return new HashMap<>();
    }

    return Stream.of(metadatas).collect(Collectors.toMap(item -> item.getString("key"), item -> {
        Metadata.ValueType valueType = item.getEnum("type");
        switch (valueType) {
            case Boolean:
                return item.getBoolean("value");
            case Short:
            case Integer:
            case Long:
                return item.getNumber("value");
            case BigDecimal:
                return new BigDecimal(item.getString("value"));
            default:
                return item.getString("value");
        }
    }));
}
项目:holon-core    文件:AbstractRepeatableAnnotationRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
    // Single annotation
    if (annotationMetadata.isAnnotated(repeatableAnnotation.getName())) {
        register(annotationMetadata.getAnnotationAttributes(repeatableAnnotation.getName()), registry, false);
    } else if (annotationMetadata.isAnnotated(repeatableAnnotationContainer.getName())) {
        // Multiple annotations
        Map<String, Object> attributes = annotationMetadata
                .getAnnotationAttributes(repeatableAnnotationContainer.getName());
        AnnotationAttributes[] repetitions = (AnnotationAttributes[]) attributes.get("value");
        if (repetitions != null) {
            for (AnnotationAttributes repetition : repetitions) {
                register(repetition, registry, true);
            }
        }
    }
}
项目:apollo-custom    文件:ApolloConfigRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata
      .getAnnotationAttributes(EnableApolloConfig.class.getName()));
  String[] namespaces = attributes.getStringArray("value");
  int order = attributes.getNumber("order");
  PropertySourcesProcessor.addNamespaces(Lists.newArrayList(namespaces), order);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesProcessor.class.getName(),
      PropertySourcesProcessor.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
项目:lodsve-framework    文件:CacheImportSelector.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableCache.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableCache.class.getName(), importingClassMetadata.getClassName()));

    CacheMode cacheMode = attributes.getEnum(CACHE_MODE_ATTRIBUTE_NAME);

    if (cacheMode == CacheMode.EHCAHE) {
        return new String[]{EhcacheCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.GUAVA) {
        return new String[]{GuavaCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.REDIS) {
        return new String[]{RedisCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.MEMCACHED) {
        return new String[]{MemcachedCacheConfiguration.class.getName()};
    } else if (cacheMode == CacheMode.OSCACHE) {
        return new String[]{OscacheCacheConfiguration.class.getName()};
    }

    return new String[0];
}
项目:lodsve-framework    文件:SearchConfigurationSelector.java   
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableSearch.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableSearch.class.getName(), importingClassMetadata.getClassName()));

    List<String> imports = new ArrayList<>();

    SearchType searchType = attributes.getEnum(SEARCH_TYPE_ATTRIBUTE_NAME);
    if (SearchType.SOLR.equals(searchType)) {
        imports.add(SolrConfiguration.class.getName());
    } else if (SearchType.LUCENE.equals(searchType)) {
        imports.add(LuceneConfiguration.class.getName());
    }

    return imports.toArray(new String[imports.size()]);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EntityScanRegistrar.java   
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(EntityScan.class.getName()));
    String[] basePackages = attributes.getAliasedStringArray("basePackages",
            EntityScan.class, metadata.getClassName());
    Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
    Set<String> packagesToScan = new LinkedHashSet<String>();
    packagesToScan.addAll(Arrays.asList(basePackages));
    for (Class<?> basePackageClass : basePackageClasses) {
        packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
    }
    if (packagesToScan.isEmpty()) {
        return Collections
                .singleton(ClassUtils.getPackageName(metadata.getClassName()));
    }
    return packagesToScan;
}
项目:lodsve-framework    文件:MongoBeanDefinitionRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableMongo.class.getName(), false));
    Assert.notNull(attributes, String.format("@%s is not present on importing class '%s' as expected", EnableMongo.class.getName(), metadata.getClassName()));

    String[] domainPackage = attributes.getStringArray(DOMAIN_PACKAGES_ATTRIBUTE_NAME);
    if (ArrayUtils.isEmpty(domainPackage)) {
        domainPackage = findDefaultPackage(metadata);
    }

    String[] basePackages = attributes.getStringArray(BASE_PACKAGES_ATTRIBUTE_NAME);
    if (ArrayUtils.isEmpty(basePackages)) {
        domainPackage = findDefaultPackage(metadata);
    }

    initMongoDataSource(attributes);
    initMongoMappingContext(domainPackage);
    initMappingContextIsNewStrategyFactory();
    initMappingConverter();
    initMongoPersistentEntityIndexCreator();
    initMongoTemplate();
    initMongoRepositoryFactory();
    initMongoRepository(metadata, registry);

    BeanRegisterUtils.registerBeans(BEAN_DEFINITION_MAP, registry);
}
项目:spring    文件:AnnotationScopeMetadataResolver.java   
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
        if (attributes != null) {
            metadata.setScopeName(attributes.getAliasedString("value", this.scopeAnnotationType, definition.getSource()));
            ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
            if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
                proxyMode = this.defaultProxyMode;
            }
            metadata.setScopedProxyMode(proxyMode);
        }
    }
    return metadata;
}
项目:spring4-understanding    文件:AdviceModeImportSelector.java   
/**
 * This implementation resolves the type of annotation from generic metadata and
 * validates that (a) the annotation is in fact present on the importing
 * {@code @Configuration} class and (b) that the given annotation has an
 * {@linkplain #getAdviceModeAttributeName() advice mode attribute} of type
 * {@link AdviceMode}.
 * <p>The {@link #selectImports(AdviceMode)} method is then invoked, allowing the
 * concrete implementation to choose imports in a safe and convenient fashion.
 * @throws IllegalArgumentException if expected annotation {@code A} is not present
 * on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)}
 * returns {@code null}
 */
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
    Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
    AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
    if (attributes == null) {
        throw new IllegalArgumentException(String.format(
            "@%s is not present on importing class '%s' as expected",
            annoType.getSimpleName(), importingClassMetadata.getClassName()));
    }

    AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());
    String[] imports = selectImports(adviceMode);
    if (imports == null) {
        throw new IllegalArgumentException(String.format("Unknown AdviceMode: '%s'", adviceMode));
    }
    return imports;
}
项目:spring-boot-concourse    文件:EnableAutoConfigurationImportSelector.java   
@Override
public String[] selectImports(AnnotationMetadata metadata) {
    if (!isEnabled(metadata)) {
        return NO_IMPORTS;
    }
    try {
        AnnotationAttributes attributes = getAttributes(metadata);
        List<String> configurations = getCandidateConfigurations(metadata,
                attributes);
        configurations = removeDuplicates(configurations);
        Set<String> exclusions = getExclusions(metadata, attributes);
        configurations.removeAll(exclusions);
        configurations = sort(configurations);
        recordWithConditionEvaluationReport(configurations, exclusions);
        return configurations.toArray(new String[configurations.size()]);
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目:spring4-understanding    文件:AnnotationBeanNameGenerator.java   
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
        AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
        if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
            Object value = attributes.get("value");
            if (value instanceof String) {
                String strVal = (String) value;
                if (StringUtils.hasLength(strVal)) {
                    if (beanName != null && !strVal.equals(beanName)) {
                        throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                                "component names: '" + beanName + "' versus '" + strVal + "'");
                    }
                    beanName = strVal;
                }
            }
        }
    }
    return beanName;
}
项目:spring4-understanding    文件:AnnotationAttributesReadingVisitor.java   
@Override
public void doVisitEnd(Class<?> annotationClass) {
    super.doVisitEnd(annotationClass);
    List<AnnotationAttributes> attributes = this.attributesMap.get(this.annotationType);
    if (attributes == null) {
        this.attributesMap.add(this.annotationType, this.attributes);
    }
    else {
        attributes.add(0, this.attributes);
    }
    Set<String> metaAnnotationTypeNames = new LinkedHashSet<String>();
    Annotation[] metaAnnotations = AnnotationUtils.getAnnotations(annotationClass);
    if (!ObjectUtils.isEmpty(metaAnnotations)) {
        for (Annotation metaAnnotation : metaAnnotations) {
            if (!AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotation)) {
                recursivelyCollectMetaAnnotations(metaAnnotationTypeNames, metaAnnotation);
            }
        }
    }
    if (this.metaAnnotationMap != null) {
        this.metaAnnotationMap.put(annotationClass.getName(), metaAnnotationTypeNames);
    }
}
项目:spring4-understanding    文件:AnnotationMetadataTests.java   
private void assertMultipleAnnotationsWithIdenticalAttributeNames(AnnotationMetadata metadata) {
    AnnotationAttributes attributes1 = (AnnotationAttributes) metadata.getAnnotationAttributes(
            NamedAnnotation1.class.getName(), false);
    String name1 = attributes1.getString("name");
    assertThat("name of NamedAnnotation1", name1, is("name 1"));

    AnnotationAttributes attributes2 = (AnnotationAttributes) metadata.getAnnotationAttributes(
            NamedAnnotation2.class.getName(), false);
    String name2 = attributes2.getString("name");
    assertThat("name of NamedAnnotation2", name2, is("name 2"));

    AnnotationAttributes attributes3 = (AnnotationAttributes) metadata.getAnnotationAttributes(
            NamedAnnotation3.class.getName(), false);
    String name3 = attributes3.getString("name");
    assertThat("name of NamedAnnotation3", name3, is("name 3"));
}
项目:spring-content    文件:StoreUtils.java   
public static String[] getBasePackages(AnnotationAttributes attributes, String[] defaultPackages) {

    String[] value = attributes.getStringArray("value");
    String[] basePackages = attributes.getStringArray(BASE_PACKAGES);
    Class<?>[] basePackageClasses = attributes.getClassArray(BASE_PACKAGE_CLASSES);

    // Default configuration - return package of annotated class
    if (value.length == 0 && basePackages.length == 0 && basePackageClasses.length == 0) {
        return defaultPackages;
    }

    Set<String> packages = new HashSet<String>();
    packages.addAll(Arrays.asList(value));
    packages.addAll(Arrays.asList(basePackages));

    for (Class<?> typeName : basePackageClasses) {
        packages.add(ClassUtils.getPackageName(typeName));
    }

    return packages.toArray(new String[] {});
}
项目:my-spring-cache-redis    文件:AnnotationScopeMetadataResolver.java   
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        AnnotationAttributes attributes = AnnotationConfigUtils.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);
        }
    }
    return metadata;
}
项目:my-spring-cache-redis    文件:AnnotationBeanNameGenerator.java   
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
        AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
        if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
            Object value = attributes.get("value");
            if (value instanceof String) {
                String strVal = (String) value;
                if (StringUtils.hasLength(strVal)) {
                    if (beanName != null && !strVal.equals(beanName)) {
                        throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                                "component names: '" + beanName + "' versus '" + strVal + "'");
                    }
                    beanName = strVal;
                }
            }
        }
    }
    return beanName;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServletComponentScanRegistrar.java   
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(
            metadata.getAnnotationAttributes(ServletComponentScan.class.getName()));
    String[] basePackages = attributes.getStringArray("basePackages");
    Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
    Set<String> packagesToScan = new LinkedHashSet<String>();
    packagesToScan.addAll(Arrays.asList(basePackages));
    for (Class<?> basePackageClass : basePackageClasses) {
        packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
    }
    if (packagesToScan.isEmpty()) {
        return Collections
                .singleton(ClassUtils.getPackageName(metadata.getClassName()));
    }
    return packagesToScan;
}
项目:cereebro    文件:OnEnabledDetectorCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledDetector.class.getName()));
    final String name = attributes.getString("value");
    final String prefix = attributes.getString("prefix");
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
            prefix + "." + name + ".");
    Boolean enabled = resolver.getProperty("enabled", Boolean.class, true);
    return new ConditionOutcome(enabled, ConditionMessage.forCondition(ConditionalOnEnabledDetector.class, name)
            .because(enabled ? "enabled" : "disabled"));
}
项目:cereebro    文件:RelationshipHintsAnnotationRelationshipDetector.java   
@Override
protected Set<Relationship> extractFromAnnotationAttributes(Map<String, Object> annotationAttributes) {
    Set<Relationship> result = new HashSet<>();
    AnnotationAttributes[] dependencies = (AnnotationAttributes[]) annotationAttributes.get("dependencies");
    for (AnnotationAttributes dependency : dependencies) {
        result.add(Dependency.on(component(dependency)));
    }
    AnnotationAttributes[] consumers = (AnnotationAttributes[]) annotationAttributes.get("consumers");
    for (AnnotationAttributes consumer : consumers) {
        result.add(Consumer.by(component(consumer)));
    }
    return result;
}
项目:JRediClients    文件:RedissonHttpSessionConfiguration.java   
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableRedissonHttpSession.class.getName());
    AnnotationAttributes attrs = AnnotationAttributes.fromMap(map);
    keyPrefix = attrs.getString("keyPrefix");
    maxInactiveIntervalInSeconds = attrs.getNumber("maxInactiveIntervalInSeconds");
}
项目:spring-data-generator    文件:ScanningConfigurationSupport.java   
public ScanningConfigurationSupport(AnnotationMetadata annotationMetadata, AnnotationAttributes attributes, Environment environment){
    Assert.notNull(environment, "Environment must not be null!");
    Assert.notNull(environment, "AnnotationMetadata must not be null!");
    this.environment = environment;
    this.attributes = attributes;
    this.annotationMetadata = annotationMetadata;
    this.entityPackage = this.attributes.getStringArray("entityPackage");
    this.onlyAnnotations = this.attributes.getBoolean("onlyAnnotations");
}
项目:spring-data-generator    文件:AbstractTemplateProvider.java   
public AbstractTemplateProvider(AnnotationAttributes attributes) {
    Assert.notNull(attributes, "AnnotationAttributes must not be null!");
    this.excludeClasses = attributes.getClassArray(getExcludeClasses());
    this.postfix = attributes.getString(getPostfix());
    this.debug = attributes.getBoolean("debug");
    this.overwrite = attributes.getBoolean("overwrite");
    if (excludeClasses.length > 0 && debug) {
        SDLogger.debug(String.format("Exclude %s %s in the %s generator", excludeClasses.length, excludeClasses.length == 1 ? "entity":"entities", postfix));
    }
}
项目:wamp2spring    文件:WampConfiguration.java   
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> attributes = AnnotationAttributes.fromMap(importMetadata
            .getAnnotationAttributes(EnableWamp.class.getName(), false));
    if (attributes != null) {
        Feature[] disableFeatures = (Feature[]) attributes.get("disable");
        if (disableFeatures != null) {
            for (Feature disableFeature : disableFeatures) {
                this.features.disable(disableFeature);
            }
        }
    }
}
项目:Your-Microservice    文件:YourMicroserviceBeanConfiguration.java   
/**
 * setImportMetadata
 *
 * @param importMetadata Annotations Metadata to validate...
 */
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableYourMicroservice.class.getName());
    this.enableYourMicroservice = AnnotationAttributes.fromMap(map);
    if (this.enableYourMicroservice == null) {
        String message =
                "@EnableYourMicroservice is not present on importing class " + importMetadata.getClassName();
        LOGGER.error(message);
        throw new IllegalArgumentException(message);
    }
}
项目:azure-spring-boot    文件:TestAutoConfigurationPackageRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata,
                                    BeanDefinitionRegistry registry) {
    final AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(
                    TestAutoConfigurationPackage.class.getName(), true));
    AutoConfigurationPackages.register(registry,
            ClassUtils.getPackageName(attributes.getString("value")));
}
项目:spring-data-snowdrop    文件:JpaWithSnowdropRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata importMetadata, BeanDefinitionRegistry registry) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(
          importMetadata.getAnnotationAttributes(JpaWithSnowdropConfiguration.class.getName(), false));
  if (attributes == null) {
    throw new IllegalArgumentException(
            "@JpaWithSnowdropConfiguration is not present on importing class " + importMetadata.getClassName());
  }
  registry.registerBeanDefinition(
          JpaRepositoryFactoryBeanSnowdropPostProcessor.class.getName(),
          buildPostProcessorDefinition(importMetadata, attributes)
  );
}
项目:appstatus-spring-boot-starter    文件:AbstractAppstatusImportAware.java   
@Override
public void setImportMetadata(AnnotationMetadata annotationMetadata) {
    Map<String, Object> map = annotationMetadata.getAnnotationAttributes(starterClass.getName());
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(map);

    initialize(attributes, new AppstatusConfigBuilder(attributes));
}
项目:appstatus-spring-boot-starter    文件:EnableAppStatusTestConfig.java   
@Override
protected void initialize(AnnotationAttributes attributes, AppstatusConfigBuilder configBuilder) {
    this.attributes = attributes;
    this.configuration = configBuilder.set("testAttribute", "testAttribute")
                                      .build();

}
项目:appstatus-spring-boot-starter    文件:AppStatusServiceConfig.java   
@Override
protected void initialize(AnnotationAttributes attributes, AppstatusConfigBuilder configBuilder) {
    this.configuration = configBuilder.set("services.log", "log")
                                      .set("services.log.format", "logFormat")
                                      .set("services.minMaxDelay", "minMaxDelay")
                                      .set("services.useThreadLocal", "useThreadLocal")
                                      .build();

    this.pointcuts = Arrays.asList(attributes.getStringArray("pointcuts"));
}
项目:appstatus-spring-boot-starter    文件:AppStatusBatchConfig.java   
@Override
protected void initialize(AnnotationAttributes attributes, AppstatusConfigBuilder builder) {
    this.configuration = builder.set("batch.logInterval", "logInterval")
                                .set("batch.zombieInterval", "zombieInterval")
                                .build();

    this.tableName = attributes.getString("tableName");
    this.daoClass = attributes.getClass("batchDaoClass");
}
项目:lams    文件:AbstractAsyncConfiguration.java   
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    this.enableAsync = AnnotationAttributes.fromMap(
            importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
    Assert.notNull(this.enableAsync,
            "@EnableAsync is not present on importing class " + importMetadata.getClassName());
}
项目:lams    文件:JtaTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, javax.transaction.Transactional.class.getName());
    if (ann != null) {
        return parseTransactionAnnotation(ann);
    }
    else {
        return null;
    }
}
项目:lams    文件:SpringTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, Transactional.class.getName());
    if (ann != null) {
        return parseTransactionAnnotation(ann);
    }
    else {
        return null;
    }
}
项目:lams    文件:AbstractTransactionManagementConfiguration.java   
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    this.enableTx = AnnotationAttributes.fromMap(
            importMetadata.getAnnotationAttributes(EnableTransactionManagement.class.getName(), false));
    Assert.notNull(this.enableTx,
            "@EnableTransactionManagement is not present on importing class " + importMetadata.getClassName());
}
项目:lams    文件:AdviceModeImportSelector.java   
/**
 * This implementation resolves the type of annotation from generic metadata and
 * validates that (a) the annotation is in fact present on the importing
 * {@code @Configuration} class and (b) that the given annotation has an
 * {@linkplain #getAdviceModeAttributeName() advice mode attribute} of type
 * {@link AdviceMode}.
 * <p>The {@link #selectImports(AdviceMode)} method is then invoked, allowing the
 * concrete implementation to choose imports in a safe and convenient fashion.
 * @throws IllegalArgumentException if expected annotation {@code A} is not present
 * on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)}
 * returns {@code null}
 */
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
    Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
    AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
    Assert.notNull(attributes, String.format(
            "@%s is not present on importing class '%s' as expected",
            annoType.getSimpleName(), importingClassMetadata.getClassName()));

    AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());
    String[] imports = selectImports(adviceMode);
    Assert.notNull(imports, String.format("Unknown AdviceMode: '%s'", adviceMode));
    return imports;
}