if (factory.containsSingleton(name)) {
log.debug("Context found in parent, destroying: {}", name);
FileSystemXmlApplicationContext ctx = (FileSystemXmlApplicationContext) factory.getSingleton(name);
if (ctx.isRunning()) {
log.debug("Context was running, attempting to stop");
ctx.stop();
}
if (ctx.isActive()) {
log.debug("Context is active, attempting to close");
ctx.close();
} else {