You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ra...@apache.org on 2009/06/29 10:57:13 UTC

svn commit: r789263 - in /tuscany/branches/sca-java-1.x/modules: implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/ implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/...

Author: ramkumar
Date: Mon Jun 29 08:57:12 2009
New Revision: 789263

URL: http://svn.apache.org/viewvc?rev=789263&view=rev
Log:
Fixes for TUSCANY-3104

Modified:
    tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
    tuscany/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java

Modified: tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java?rev=789263&r1=789262&r2=789263&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java (original)
+++ tuscany/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java Mon Jun 29 08:57:12 2009
@@ -40,7 +40,6 @@
 import org.springframework.beans.factory.xml.XmlBeanFactory;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.UrlResource;
 import org.springframework.core.SpringVersion;
@@ -84,58 +83,52 @@
     }
 
     /**
-     * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+     * Create appropriate ApplicationContext by reading the bean definitions.
      */
-//    private Object createApplicationContext(SCAParentApplicationContext scaParentContext) {
-
     private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext, URL resource) {
 
         XmlBeanFactory beanFactory = new XmlBeanFactory(new UrlResource(resource));
         AbstractApplicationContext appContext = null;
         
         for (String bean : beanFactory.getBeanDefinitionNames()) {
-                String beanClassName = (beanFactory.getType(bean)).getName();
-                if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1 || 
-                                beanClassName.indexOf(".FileSystemXmlApplicationContext") != -1) 
-                {
-                        BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);                           
-                        String[] listValues = null;
-                        List<ConstructorArgumentValues.ValueHolder> conArgs = 
-                                beanDef.getConstructorArgumentValues().getGenericArgumentValues();
-                        for (ConstructorArgumentValues.ValueHolder conArg : conArgs) {
-                                if (conArg.getValue() instanceof TypedStringValue) {
-                                        TypedStringValue value = (TypedStringValue) conArg.getValue();
-                                        if (value.getValue().indexOf(".xml") != -1)
-                                                listValues = new String[]{value.getValue()};
-                                }
-                                if (conArg.getValue() instanceof ManagedList) {
-                                        Iterator itml = ((ManagedList)conArg.getValue()).iterator();
-                                        StringBuffer values = new StringBuffer();
-                                        while (itml.hasNext()) {
-                                                TypedStringValue next = (TypedStringValue)itml.next();
-                                                if (next.getValue().indexOf(".xml") != -1) {
-                                                        values.append(next.getValue());
-                                                        values.append("~");
-                                                }
+            String beanClassName = (beanFactory.getType(bean)).getName();
+            // Using FileSystemXmlApplicationContext is not supported, as the 
+            // SCA runtime does not support paths relative to current VM working directory.
+            if (beanClassName.indexOf(".FileSystemXmlApplicationContext") != -1) {
+            	throw new RuntimeException("Usage of FileSystemXmlApplicationContext Bean is not supported");
+            }
+            	
+            if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {
+            	BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);                           
+                String[] listValues = null;
+                List<ConstructorArgumentValues.ValueHolder> conArgs = 
+                        beanDef.getConstructorArgumentValues().getGenericArgumentValues();
+                for (ConstructorArgumentValues.ValueHolder conArg : conArgs) {
+                        if (conArg.getValue() instanceof TypedStringValue) {
+                                TypedStringValue value = (TypedStringValue) conArg.getValue();
+                                if (value.getValue().indexOf(".xml") != -1)
+                                        listValues = new String[]{value.getValue()};
+                        }
+                        if (conArg.getValue() instanceof ManagedList) {
+                                Iterator itml = ((ManagedList)conArg.getValue()).iterator();
+                                StringBuffer values = new StringBuffer();
+                                while (itml.hasNext()) {
+                                        TypedStringValue next = (TypedStringValue)itml.next();
+                                        if (next.getValue().indexOf(".xml") != -1) {
+                                                values.append(next.getValue());
+                                                values.append("~");
                                         }
-                                        listValues = (values.toString()).split("~");                                    
                                 }
+                                listValues = (values.toString()).split("~");                                    
                         }
-                        
-                        if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {                                                                   
-                                appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);                                   
-                                appContext.refresh();
-                                if (isAnnotationSupported)
-                                	includeAnnotationProcessors(appContext.getBeanFactory());
-                                return appContext;
-                        } else {
-                                appContext = new FileSystemXmlApplicationContext(listValues, false, scaParentContext);                                  
-                                appContext.refresh();
-                                if (isAnnotationSupported)
-                                	includeAnnotationProcessors(appContext.getBeanFactory());
-                                return appContext;
-                        }
-                }               
+                }            
+                                                                                   
+	            appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);                                   
+	            appContext.refresh();
+	            if (isAnnotationSupported)
+	            	includeAnnotationProcessors(appContext.getBeanFactory());
+	            return appContext;
+            }               
         }
         
         // use the generic application context as default 

Modified: tuscany/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java?rev=789263&r1=789262&r2=789263&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java (original)
+++ tuscany/branches/sca-java-1.x/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java Mon Jun 29 08:57:12 2009
@@ -294,8 +294,7 @@
                             	String value = reader.getAttributeValue(null, "value");
                             	constructorArg.addValue(value);
                             	if ((value.indexOf(".xml") != -1)) {
-                                    if ((bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) ||
-                                        (bean.getClassName().indexOf(".FileSystemXmlApplicationContext") != -1)) {                                    
+                                    if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {                                 
                                         XMLStreamReader creader = getApplicationContextReader(value);
                                         // Read the context definition for the constructor-arg resources
                                         readContextDefinition(creader, beans, services, references, scaproperties);
@@ -316,8 +315,7 @@
                             	constructorArg.addValue(value);
                                 // Identify the XML resource specified for the constructor-arg element
                                 if ((value.indexOf(".xml") != -1)) {
-                                    if ((bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) ||
-                                        (bean.getClassName().indexOf(".FileSystemXmlApplicationContext") != -1)) {                                    
+                                    if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext") != -1) {                                   
                                         XMLStreamReader creader = getApplicationContextReader(value);
                                         // Read the context definition for the constructor-arg resources
                                         readContextDefinition(creader, beans, services, references, scaproperties);