From 55b366b52798daae7baae5b2b118b95e188054d0 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 17 Aug 2010 22:53:30 +0000 Subject: Use the same way to create application context git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@986515 13f79535-47bb-0310-9956-ffa450edef68 --- .../spring/runtime/context/SpringContextTie.java | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany') diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java index d5a330c916..b3b18abbd4 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java @@ -33,7 +33,6 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.UrlResource; @@ -74,27 +73,20 @@ public class SpringContextTie { private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext, List resources) { - XmlBeanFactory beanFactory = null; - AbstractApplicationContext appContext = null; - - if (resources.size() > 1) { - GenericApplicationContext appCtx = - new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader()); - XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); - for (URL resource : resources) { - xmlReader.loadBeanDefinitions(new UrlResource(resource)); - } - xmlReader.setBeanClassLoader(implementation.getClassLoader()); - includeAnnotationProcessors(appCtx.getBeanFactory()); - return appCtx; + GenericApplicationContext appCtx = + new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader()); + XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); + + // REVIEW: [rfeng] How do we control the schema validation + xmlReader.setValidating(false); + + for (URL resource : resources) { + xmlReader.loadBeanDefinitions(new UrlResource(resource)); } + xmlReader.setBeanClassLoader(implementation.getClassLoader()); + includeAnnotationProcessors(appCtx.getBeanFactory()); + return appCtx; - // use the generic application context as default - beanFactory = new XmlBeanFactory(new UrlResource(resources.get(0))); - beanFactory.setBeanClassLoader(implementation.getClassLoader()); - includeAnnotationProcessors(beanFactory); - appContext = new SCAGenericApplicationContext(beanFactory, scaParentContext, implementation.getClassLoader()); - return appContext; } public Object getBean(String id) throws BeansException { -- cgit v1.2.3