ConfigurableApplicationContext context = null;
final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(definition), false);
final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
final DelegatingContextLoader delegatingLoader = delegatingContextLoaderRegistry.getDelegatingLoader(definition.getType());
try {
if (moduleLoader != null) {
if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using ModuleLoader " + moduleLoader);
context = loadApplicationContext(application, classLoader, moduleLoader, parent, definition);
final String applicationId = application.getId();
moduleLoader.afterRefresh(applicationId, context, definition);
}
else if (delegatingLoader != null) {
if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using DelegatingContextLoader " + moduleLoader);
context = delegatingLoader.loadApplicationContext(parent, definition);
}
else {
throw new ConfigurationException("No " + ModuleLoader.class.getName() + " or "
+ DelegatingContextLoader.class.getName() + " specified for module definition type " + definition.getType());
}