providerContext.start();
try {
ClassPathXmlApplicationContext byNameContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/aop-autowire-byname.xml");
byNameContext.start();
try {
DemoActionBySetter demoActionBySetter = (DemoActionBySetter) byNameContext.getBean("demoActionBySetter");
assertNotNull(demoActionBySetter.getDemoService());
assertEquals("aop:say:hello", demoActionBySetter.getDemoService().sayName("hello"));
DemoActionByAnnotation demoActionByAnnotation = (DemoActionByAnnotation) byNameContext.getBean("demoActionByAnnotation");
assertNotNull(demoActionByAnnotation.getDemoService());
assertEquals("aop:say:hello", demoActionByAnnotation.getDemoService().sayName("hello"));
} finally {
byNameContext.stop();
byNameContext.close();
}
ClassPathXmlApplicationContext byTypeContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/aop-autowire-bytype.xml");
byTypeContext.start();
try {
DemoActionBySetter demoActionBySetter = (DemoActionBySetter) byTypeContext.getBean("demoActionBySetter");
assertNotNull(demoActionBySetter.getDemoService());
assertEquals("aop:say:hello", demoActionBySetter.getDemoService().sayName("hello"));
DemoActionByAnnotation demoActionByAnnotation = (DemoActionByAnnotation) byTypeContext.getBean("demoActionByAnnotation");
assertNotNull(demoActionByAnnotation.getDemoService());
assertEquals("aop:say:hello", demoActionByAnnotation.getDemoService().sayName("hello"));
} finally {
byTypeContext.stop();