public class ContextChecker { public static void main( String[] args ) { AbstractRefreshableApplicationContext ctx = new ClassPathXmlApplicationContext( "classpath*:/beans.xml" ); ctx.setAllowCircularReferences( false ); ctx.refresh(); } }
/** * Sets a default config location if no explicit config location specified. * @see #getDefaultConfigLocations * @see #setConfigLocations */ public void refresh() throws BeansException { if (this.configLocations == null || this.configLocations.length == 0) { setConfigLocations(getDefaultConfigLocations()); } super.refresh(); }
public ApplicationContext createApplicatonContext(FlowDefinition processDefinition, Map<String, ? extends Object> projectProperties, final ApplicationContext parent) { Resource[] configResources = null; ClassLoader classLoader = this.getClass().getClassLoader(); ClassLoader originalClassLoader = ClassUtils.overrideThreadContextClassLoader(classLoader); try { Assert.notNull(processDefinition); Assert.notNull(processDefinition.getProcessingConfiguration()); Resource processContext = new InputStreamResource(processDefinition.getProcessingConfiguration()); configResources = createResources(processContext, originalClassLoader); } finally { if (originalClassLoader != null) { Thread.currentThread().setContextClassLoader(originalClassLoader); } } ProcessResourceLocator processResourceLocator = new ProcessResourceLocator(processDefinition); externalResourceLocators.add(processResourceLocator); Properties properties = convertProperties(projectProperties); AbstractRefreshableApplicationContext applicationContext = new ProcessXmlApplicationContext(configResources, externalResourceLocators); // BeanPostProcessor applicationContext.setParent(parent); for (BeanFactoryPostProcessor postProcessor : postProcessors) { if (postProcessor instanceof PropertiesLoaderSupport) { ((PropertiesLoaderSupport) postProcessor).setProperties(properties); } applicationContext.addBeanFactoryPostProcessor(postProcessor); } applicationContext.refresh(); return applicationContext; }