ConfigurableApplicationContext context = moduleLoader.newApplicationContext(application, parent, definition, classLoader);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
addBeanPostProcessors(application, definition, beanFactory);
final String applicationId = application.getId();
BeanDefinitionReader reader = moduleLoader.newBeanDefinitionReader(applicationId, context, definition);
if (reader != null) {
//if this is null, then we assume moduleLoader or refresh takes care of this
if (reader instanceof AbstractBeanDefinitionReader) {
((AbstractBeanDefinitionReader) reader).setBeanClassLoader(classLoader);
}
final Resource[] resources = moduleLoader.getSpringConfigResources(applicationId, definition, classLoader);
reader.loadBeanDefinitions(resources);
}
moduleLoader.handleRefresh(applicationId, context, definition);
return context;
}