use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class AutowiredConfigurationTests method testAutowiredAnnotatedConstructorSupported.
@Test
public void testAutowiredAnnotatedConstructorSupported() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new ClassPathResource("annotation-config.xml", MultipleConstructorConfig.class));
GenericApplicationContext ctx = new GenericApplicationContext(factory);
ctx.registerBeanDefinition("config1", new RootBeanDefinition(MultipleConstructorConfig.class));
ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
ctx.refresh();
assertSame(ctx.getBean(MultipleConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class AutowiredConfigurationTests method testObjectFactoryConstructorWithTypeVariable.
@Test
public void testObjectFactoryConstructorWithTypeVariable() {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new ClassPathResource("annotation-config.xml", ObjectFactoryConstructorConfig.class));
GenericApplicationContext ctx = new GenericApplicationContext(factory);
ctx.registerBeanDefinition("config1", new RootBeanDefinition(ObjectFactoryConstructorConfig.class));
ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
ctx.refresh();
assertSame(ctx.getBean(ObjectFactoryConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class HybridContextLoader method loadBeanDefinitions.
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
// Order doesn't matter: <bean> always wins over @Bean.
new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class TxNamespaceHandlerEventTests method setUp.
@Before
public void setUp() throws Exception {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.setEventListener(this.eventListener);
reader.loadBeanDefinitions(new ClassPathResource("txNamespaceHandlerTests.xml", getClass()));
}
use of org.springframework.beans.factory.xml.XmlBeanDefinitionReader in project spring-framework by spring-projects.
the class TestBeanAdvisor method testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough.
@Test
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext();
new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"), getClass()));
for (int i = 0; i < 10000; i++) {
ac.registerBeanDefinition("singleton" + i, new RootBeanDefinition(NestedTestBean.class));
}
StopWatch sw = new StopWatch();
sw.start("Singleton Creation");
ac.refresh();
sw.stop();
// What's a reasonable expectation for _any_ server or developer machine load?
// 8 seconds?
assertStopWatchTimeLimit(sw, 8000);
}
Aggregations