final String moduleName = currentDefinition.getName();
logger.info("Loading definition " + moduleName);
final ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
final ServiceRegistry serviceRegistry = application.getServiceRegistry();
if (moduleStateHolder.getModule(moduleName) == null) {
ModuleRuntime moduleRuntime = getModuleRuntime(currentDefinition);
try {
RuntimeModule runtimeModule = moduleRuntime.loadRuntimeModule(application, currentDefinition);
moduleStateHolder.putModule(moduleName, runtimeModule);
}
catch (Throwable e) {
try {
serviceRegistry.evictModuleServices(moduleName);
} catch (Exception ee) {
logger.error("Error evicting modules from module: " + moduleName, ee);
}
logger.error("Failed to handle loading of application module: " + moduleName, e);