use of org.springframework.core.annotation.AnnotationAttributes in project spring-framework by spring-projects.
the class ImportAwareTests method indirectlyAnnotatedWithImport.
@Test
public void indirectlyAnnotatedWithImport() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(IndirectlyImportingConfig.class);
ctx.refresh();
assertThat(ctx.getBean("importedConfigBean")).isNotNull();
ImportedConfig importAwareConfig = ctx.getBean(ImportedConfig.class);
AnnotationMetadata importMetadata = importAwareConfig.importMetadata;
assertThat(importMetadata).isNotNull();
assertThat(importMetadata.getClassName()).isEqualTo(IndirectlyImportingConfig.class.getName());
AnnotationAttributes enableAttribs = AnnotationConfigUtils.attributesFor(importMetadata, EnableImportedConfig.class);
String foo = enableAttribs.getString("foo");
assertThat(foo).isEqualTo("xyz");
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-data-mongodb by spring-projects.
the class MongoRepositoryConfigurationExtension method postProcess.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource)
*/
@Override
public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) {
AnnotationAttributes attributes = config.getAttributes();
builder.addPropertyReference("mongoOperations", attributes.getString("mongoTemplateRef"));
builder.addPropertyValue("createIndexesForQueryMethods", attributes.getBoolean("createIndexesForQueryMethods"));
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryConfigurationExtension method postProcess.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource)
*/
@Override
public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) {
AnnotationAttributes attributes = config.getAttributes();
builder.addPropertyReference("reactiveMongoOperations", attributes.getString("reactiveMongoTemplateRef"));
builder.addPropertyValue("createIndexesForQueryMethods", attributes.getBoolean("createIndexesForQueryMethods"));
}
use of org.springframework.core.annotation.AnnotationAttributes in project cuba by cuba-platform.
the class OnConfigPropertyCondition method matches.
@Override
public boolean matches(@Nonnull ConditionContext context, @Nonnull AnnotatedTypeMetadata metadata) {
Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnAppProperty.class.getName());
if (attributes != null) {
String configPropertyName = (String) attributes.get("property");
String configPropertyValue = (String) attributes.get("value");
String configPropertyDefaultValue = (String) attributes.get("defaultValue");
return isConditionSatisfied(configPropertyName, configPropertyValue, configPropertyDefaultValue);
} else {
Map<String, Object> valueMap = metadata.getAnnotationAttributes(ConditionalOnAppProperties.class.getName());
if (valueMap == null) {
return true;
}
AnnotationAttributes[] properties = (AnnotationAttributes[]) valueMap.get("value");
for (AnnotationAttributes propertyCondition : properties) {
String configPropertyName = (String) propertyCondition.get("property");
String configPropertyValue = (String) propertyCondition.get("value");
String configPropertyDefaultValue = (String) propertyCondition.get("defaultValue");
if (!isConditionSatisfied(configPropertyName, configPropertyValue, configPropertyDefaultValue)) {
return false;
}
}
}
return true;
}
use of org.springframework.core.annotation.AnnotationAttributes in project leopard by tanhaichao.
the class OptionScanner method getValue.
protected String getValue(BeanDefinition beanDefinition) {
AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata();
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(Option.class.getName(), false));
return attributes.getString("value");
}
Aggregations