}
public boolean process(ModuleStateHolder moduleStateHolder, RootModuleDefinition newRootDefinition,
ModuleDefinition moduleDefinition) {
ModuleLoader moduleLoader = moduleLoaderRegistry.getModuleLoader(newRootDefinition.getType());
ConfigurableApplicationContext parentContext = moduleStateHolder.getRootModuleContext();
ClassLoader classLoader = parentContext.getClassLoader();
RootModuleDefinition existingModuleDefinition = moduleStateHolder.getRootModuleDefinition();
Resource[] existingResources = moduleLoader.getSpringConfigResources(existingModuleDefinition, classLoader);
Resource[] newResources = moduleLoader.getSpringConfigResources(newRootDefinition, classLoader);
// compare difference
List<Resource> existingResourceList = newResourceList(existingResources);
List<Resource> newResourceList = newResourceList(newResources);
List<Resource> toAddList = new ArrayList<Resource>();
for (Resource resource : newResourceList) {
if (!existingResourceList.contains(resource)) {
toAddList.add(resource);
}
}
BeanDefinitionReader beanDefinitionReader = moduleLoader.newBeanDefinitionReader(parentContext,
newRootDefinition);
beanDefinitionReader.loadBeanDefinitions(toAddList.toArray(new Resource[toAddList.size()]));
return true;
}