Only lookup abstract features from context.

This commit is contained in:
Spencer Gibb
2015-09-25 16:00:58 -06:00
parent be1c4ae881
commit 0bb2f48e4c
2 changed files with 12 additions and 15 deletions

View File

@@ -55,20 +55,22 @@ public class FeaturesEndpoint extends AbstractEndpoint<FeaturesEndpoint.Features
}
private void addAbstractFeature(Features features, Class type) {
addFeature(features, new NamedFeature(type.getSimpleName(), type));
String featureName = type.getSimpleName();
try {
Object bean = context.getBean(type);
Class<?> beanClass = bean.getClass();
addFeature(features, new NamedFeature(featureName, beanClass));
} catch (NoSuchBeanDefinitionException e) {
features.getDisabled().add(featureName);
}
}
private void addFeature(Features features, NamedFeature feature) {
try {
Object bean = context.getBean(feature.getType());
Class<?> beanClass = bean.getClass();
Class<?> type = feature.getType();
features.getEnabled().add(new Feature(feature.getName(),
beanClass.getCanonicalName(),
beanClass.getPackage().getImplementationVersion(),
beanClass.getPackage().getImplementationVendor()));
} catch (NoSuchBeanDefinitionException e) {
features.getDisabled().add(feature.getName());
}
type.getCanonicalName(),
type.getPackage().getImplementationVersion(),
type.getPackage().getImplementationVendor()));
}
@Value

View File

@@ -55,11 +55,6 @@ public class FeaturesEndpointTests {
return new Foo();
}
@Bean
Bar bar() {
return new Bar();
}
@Bean
HasFeatures localFeatures() {
return HasFeatures.builder()