}
public void process(Application application, RootModuleDefinition newRootDefinition, ModuleDefinition moduleDefinition) {
final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(newRootDefinition));
final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
ConfigurableApplicationContext parentContext = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
ClassLoader classLoader = parentContext.getClassLoader();
RootModuleDefinition existingModuleDefinition = moduleStateHolder.getRootModuleDefinition();
String applicationId = application.getId();
Resource[] existingResources = moduleLoader.getSpringConfigResources(applicationId, existingModuleDefinition, classLoader);
Resource[] newResources = moduleLoader.getSpringConfigResources(applicationId, 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(applicationId,
parentContext, newRootDefinition);
beanDefinitionReader.loadBeanDefinitions(toAddList.toArray(new Resource[toAddList.size()]));
}