@Test public void testAllowBeanOverrideFalse() { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); applicationContext.setAllowBeanDefinitionOverriding(false); applicationContext.setConfigLocation("org/springframework/batch/core/configuration/xml/BeanDefinitionOverrideTests-context.xml"); applicationContext.refresh(); } }
@Test public void registerDataValueProcessorOnlyIfNotRegistered() throws Exception { try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext()) { context.setAllowBeanDefinitionOverriding(false); context.setConfigLocation(this.xml("RegisterDataValueProcessorOnyIfNotRegistered")); context.refresh(); } }
context.setAllowBeanDefinitionOverriding(false); context.setConfigLocations(new String[]{"classpath:org/springframework/integration/channel/channel-override-config.xml"}); context.setParent(parentContext);
applicationContext = new ClassPathXmlApplicationContext(allPaths, false); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setAllowCircularReferences(false);
applicationContext = new ClassPathXmlApplicationContext(allPaths, false); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setAllowCircularReferences(true);
@Override public void startup() { long startTime = System.currentTimeMillis(); // get all spring config paths String[] allPaths = getSpringPaths(testMode, configPaths, configurationService); applicationContext = new ClassPathXmlApplicationContext(allPaths, false); // Make sure that the spring files from the config directoy can override the spring files from our jars applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setAllowCircularReferences(true); //applicationContext.registerShutdownHook(); // this interferes with the kernel shutdown hook // add the config interceptors (partially done in the xml) applicationContext .addBeanFactoryPostProcessor(new DSpaceBeanFactoryPostProcessor(parent, configurationService, testMode)); applicationContext.refresh(); if (developmentMode) { log.warn("Spring Service Manager is running in developmentMode, services will be loaded on demand only"); // TODO find a way to set this sucker to super duper lazy mode? it is currently not actually doing it } else { applicationContext.getBeanFactory().preInstantiateSingletons(); applicationContext.getBeanFactory().freezeConfiguration(); } long totalTime = System.currentTimeMillis() - startTime; log.info("Spring Service Manager started up in " + totalTime + " ms with " + applicationContext .getBeanDefinitionCount() + " services..."); }