use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class OnJndiCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(ConditionalOnJndi.class.getName()));
String[] locations = annotationAttributes.getStringArray("value");
try {
return getMatchOutcome(locations);
} catch (NoClassDefFoundError ex) {
return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnJndi.class).because("JNDI class not found"));
}
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class ConfigurationPropertiesScanRegistrar method getPackagesToScan.
private Set<String> getPackagesToScan(AnnotationMetadata metadata) {
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(ConfigurationPropertiesScan.class.getName()));
String[] basePackages = attributes.getStringArray("basePackages");
Class<?>[] basePackageClasses = attributes.getClassArray("basePackageClasses");
Set<String> packagesToScan = new LinkedHashSet<>(Arrays.asList(basePackages));
for (Class<?> basePackageClass : basePackageClasses) {
packagesToScan.add(ClassUtils.getPackageName(basePackageClass));
}
if (packagesToScan.isEmpty()) {
packagesToScan.add(ClassUtils.getPackageName(metadata.getClassName()));
}
packagesToScan.removeIf((candidate) -> !StringUtils.hasText(candidate));
return packagesToScan;
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class SpringBootConfigurationTests method proxyBeanMethodsIsEnabledByDefault.
@Test
void proxyBeanMethodsIsEnabledByDefault() {
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(DefaultSpringBootConfiguration.class, Configuration.class);
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true);
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class RequestPredicateFactoryTests method getDiscoveredOperationMethod.
private DiscoveredOperationMethod getDiscoveredOperationMethod(Class<?> source) {
Method method = source.getDeclaredMethods()[0];
AnnotationAttributes attributes = new AnnotationAttributes();
attributes.put("produces", "application/json");
return new DiscoveredOperationMethod(method, OperationType.READ, attributes);
}
use of org.springframework.core.annotation.AnnotationAttributes in project spring-boot by spring-projects.
the class ImportAutoConfigurationImportSelector method getExclusions.
@Override
protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
Set<String> exclusions = new LinkedHashSet<>();
Class<?> source = ClassUtils.resolveClassName(metadata.getClassName(), null);
for (String annotationName : ANNOTATION_NAMES) {
AnnotationAttributes merged = AnnotatedElementUtils.getMergedAnnotationAttributes(source, annotationName);
Class<?>[] exclude = (merged != null) ? merged.getClassArray("exclude") : null;
if (exclude != null) {
for (Class<?> excludeClass : exclude) {
exclusions.add(excludeClass.getName());
}
}
}
for (List<Annotation> annotations : getAnnotations(metadata).values()) {
for (Annotation annotation : annotations) {
String[] exclude = (String[]) AnnotationUtils.getAnnotationAttributes(annotation, true).get("exclude");
if (!ObjectUtils.isEmpty(exclude)) {
exclusions.addAll(Arrays.asList(exclude));
}
}
}
exclusions.addAll(getExcludeAutoConfigurationsProperty());
return exclusions;
}
Aggregations