}
}
protected WebApplicationContext createWebApplicationContext() throws BeansException {
ModuleManagementFactory factory = (ModuleManagementFactory) getServletContext().getAttribute(
WebConstants.IMPALA_FACTORY_ATTRIBUTE);
if (factory == null) {
throw new RuntimeException(ModuleManagementFactory.class.getSimpleName()
+ " not set. Have you set up your Impala context loader properly? "
+ "You need to set up a Spring context loader which will set up the parameter '"
+ WebConstants.IMPALA_FACTORY_ATTRIBUTE + "'");
}
String moduleName = getServletName();
if (!initialized) {
ModuleStateHolder moduleStateHolder = factory.getModuleStateHolder();
RootModuleDefinition rootDefinition = moduleStateHolder.cloneRootModuleDefinition();
ModuleDefinition newDefinition = newModuleDefinition(moduleName, rootDefinition);
ModuleOperation operation = factory.getModuleOperationRegistry().getOperation(
ModuleOperationConstants.AddModuleOperation);
operation.execute(new ModuleOperationInput(null, newDefinition, null));
}
ApplicationContext context = factory.getModuleStateHolder().getModuleContexts().get(moduleName);
if (!initialized) {
if (factory.containsBean("scheduledModuleChangeMonitor")) {
logger.info("Registering " + getServletName() + " for module modifications");
ModuleChangeMonitor moduleChangeMonitor = (ModuleChangeMonitor) factory
.getBean("scheduledModuleChangeMonitor");
moduleChangeMonitor.addModificationListener(this);
}
this.initialized = true;
}