Give application context a friendly display name. (#316)

Fixes gh307
This commit is contained in:
Bertrand Renuart
2018-02-02 19:05:43 +01:00
committed by Spencer Gibb
parent cdd4268b4a
commit 361494b70f

View File

@@ -113,10 +113,15 @@ public abstract class NamedContextFactory<C extends NamedContextFactory.Specific
// Uses Environment from parent as well as beans
context.setParent(this.parent);
}
context.setDisplayName(generateDisplayName(name));
context.refresh();
return context;
}
protected String generateDisplayName(String name) {
return this.getClass().getSimpleName() + "-" + name;
}
public <T> T getInstance(String name, Class<T> type) {
AnnotationConfigApplicationContext context = getContext(name);
if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,