use of org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor in project incubator-atlas by apache.
the class OnAtlasPropertyCondition method matches.
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
boolean matches = false;
String propertyName = (String) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("property");
boolean isDefault = (Boolean) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("isDefault");
String className = ((AnnotationMetadataReadingVisitor) metadata).getClassName();
try {
Configuration configuration = ApplicationProperties.get();
String configuredProperty = configuration.getString(propertyName);
if (StringUtils.isNotEmpty(configuredProperty)) {
matches = configuredProperty.equals(className);
} else if (isDefault)
matches = true;
} catch (AtlasException e) {
LOG.error("Unable to load atlas properties. Dependent bean configuration may fail");
}
return matches;
}
Aggregations