tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramku...@apache.org
Subject svn commit: r810466 - in /tuscany/branches/sca-java-1.5.1/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/sprin...
Date Wed, 02 Sep 2009 11:57:21 GMT
Author: ramkumar
Date: Wed Sep  2 11:57:20 2009
New Revision: 810466

URL: http://svn.apache.org/viewvc?rev=810466&view=rev
Log:
Fixes for TUSCANY-3249 - providing on/off feature for multiple application context support

Modified:
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
    tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java

Modified: tuscany/branches/sca-java-1.5.1/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.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
Wed Sep  2 11:57:20 2009
@@ -58,6 +58,7 @@
     private SpringImplementationStub implementation;
     private boolean isAnnotationSupported;
     private String versionSupported;
+    private boolean isMultipleContextSupport;
     
     // TUSCANY-3128
     // extension of the generic application context just to force the classloader
@@ -81,10 +82,11 @@
         }
     }
     
-    public SpringContextTie(SpringImplementationStub implementation, URL resource, boolean
annotationSupport, String versionSupported) throws Exception {
+    public SpringContextTie(SpringImplementationStub implementation, URL resource, boolean
annotationSupport, String versionSupported, boolean multipleContextSupport) throws Exception
{
         this.implementation = implementation;
         this.isAnnotationSupported = annotationSupport;
         this.versionSupported = versionSupported;
+        this.isMultipleContextSupport = multipleContextSupport;
         if (! this.versionSupported.equals("ANY")) {
         	if ((SpringVersion.getVersion()!= null) && (! SpringVersion.getVersion().equals(versionSupported)))
         		throw new RuntimeException("Unsupported version: Use only Spring Framework Version
" + versionSupported);
@@ -116,44 +118,46 @@
         beanFactory.setBeanClassLoader(implementation.getClassLoader());
         AbstractApplicationContext appContext = null;
         
-        for (String bean : beanFactory.getBeanDefinitionNames()) {
-            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[] configLocations = 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)
-                        	configLocations = 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(implementation.getClassLoader().getResource(next.getValue()).toString());
-                                values.append("~");
-                            }
-                        }
-                        configLocations = (values.toString()).split("~");               
                    
-                    }
-                }
-                
-	            appContext = new ClassPathXmlApplicationContext(configLocations, true, scaParentContext);
            
-	            if (isAnnotationSupported)
-	            	includeAnnotationProcessors(appContext.getBeanFactory());
-	            return appContext;
-            }               
+        if (isMultipleContextSupport) {
+	        for (String bean : beanFactory.getBeanDefinitionNames()) {
+	            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[] configLocations = 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)
+	                        	configLocations = 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(implementation.getClassLoader().getResource(next.getValue()).toString());
+	                                values.append("~");
+	                            }
+	                        }
+	                        configLocations = (values.toString()).split("~");              
                     
+	                    }
+	                }
+	                
+		            appContext = new ClassPathXmlApplicationContext(configLocations, true, scaParentContext);
            
+		            if (isAnnotationSupported)
+		            	includeAnnotationProcessors(appContext.getBeanFactory());
+		            return appContext;
+	            }               
+	        }
         }
         
         // use the generic application context as default 

Modified: tuscany/branches/sca-java-1.5.1/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.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
Wed Sep  2 11:57:20 2009
@@ -91,19 +91,22 @@
     private AssemblyFactory assemblyFactory;
     private JavaInterfaceFactory javaFactory;
     private PolicyFactory policyFactory;
+    private boolean isMultipleContextSupported;
 
     private SpringBeanIntrospector beanIntrospector;
 
     public SpringXMLComponentTypeLoader(ModelFactoryExtensionPoint factories,
                                         AssemblyFactory assemblyFactory,
                                         JavaInterfaceFactory javaFactory,
-                                        PolicyFactory policyFactory) {
+                                        PolicyFactory policyFactory,
+                                        boolean multipleContextSupport) {
         super();
         this.assemblyFactory = assemblyFactory;
         this.javaFactory = javaFactory;
         this.policyFactory = policyFactory;
         this.contributionFactory = factories.getFactory(ContributionFactory.class);
         this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
+        this.isMultipleContextSupported = multipleContextSupport;
     }
 
     protected Class<SpringImplementation> getImplementationClass() {
@@ -338,7 +341,7 @@
                             if (reader.getAttributeValue(null, "value") != null) {
                             	String value = reader.getAttributeValue(null, "value");
                             	constructorArg.addValue(value);
-                            	if ((value.indexOf(".xml") != -1)) {
+                            	if ((isMultipleContextSupported) && (value.indexOf(".xml")
!= -1)) {
                                     if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext")
!= -1) {
                                         XMLStreamReader creader = getApplicationContextReader(resolver,
value);
                                         // Read the context definition for the constructor-arg
resources
@@ -359,7 +362,7 @@
                             if (constructorArg != null) {
                             	constructorArg.addValue(value);
                                 // Identify the XML resource specified for the constructor-arg
element
-                                if ((value.indexOf(".xml") != -1)) {
+                                if ((isMultipleContextSupported) && (value.indexOf(".xml")
!= -1)) {
                                     if (bean.getClassName().indexOf(".ClassPathXmlApplicationContext")
!= -1) {
                                         XMLStreamReader creader = getApplicationContextReader(resolver,
value);
                                         // Read the context definition for the constructor-arg
resources

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ConfigurationPropertiesExtensionPoint.java
Wed Sep  2 11:57:20 2009
@@ -4,6 +4,8 @@
 	
 	boolean isAnnotationSupported();
 	
+	boolean isMultipleContextSupported();
+	
 	String getSupportedVersion();
 
 }

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/DefaultConfigurationPropertiesExtensionPoint.java
Wed Sep  2 11:57:20 2009
@@ -8,11 +8,17 @@
 	}
 	
 	// By default SCA annotations for implementation.spring
-	// will be supproted.
+	// will be supproted for Tuscany.
 	public boolean isAnnotationSupported() {
 		return true;
 	}
 	
+	// By default multiple application context implementation.spring
+	// will be supproted for Tuscany.
+	public boolean isMultipleContextSupported() {
+		return true;
+	}
+	
 	// By defauly all the Spring version are supported for 
 	// Tuscany.
 	public String getSupportedVersion() {

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
Wed Sep  2 11:57:20 2009
@@ -47,9 +47,10 @@
                                ProxyFactory proxyService,
                                JavaPropertyValueObjectFactory propertyValueObjectFactory,
                                boolean annotationSupport,
-                               String versionSupported) {
+                               String versionSupported,
+                               boolean multipleContextSupport) {
 
-        initTie(component, implementation, propertyValueObjectFactory, annotationSupport,
versionSupported);        
+        initTie(component, implementation, propertyValueObjectFactory, annotationSupport,
versionSupported, multipleContextSupport);        
 
     }
 
@@ -57,7 +58,8 @@
                          SpringImplementation implementation,
                          JavaPropertyValueObjectFactory propertyValueObjectFactory,
                          boolean annotationSupport,
-                         String versionSupported) {
+                         String versionSupported,
+                         boolean multipleContextSupport) {
 
         // TODO: what class loader to use?
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -69,8 +71,8 @@
             Object stub = stubConstructor.newInstance(new SpringImplementationTie(implementation,
component, propertyValueObjectFactory));
 
             Class<?> tieClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringContextTie",
true, cl);
-            Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[]{stubClass,
URL.class, boolean.class, String.class});
-            this.tie = tieConstructor.newInstance(stub, implementation.getResource(), annotationSupport,
versionSupported);
+            Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[]{stubClass,
URL.class, boolean.class, String.class, boolean.class});
+            this.tie = tieConstructor.newInstance(stub, implementation.getResource(), annotationSupport,
versionSupported, multipleContextSupport);
             
             this.startMethod = tieClass.getMethod("start");
             this.closeMethod = tieClass.getMethod("close");

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
Wed Sep  2 11:57:20 2009
@@ -52,13 +52,14 @@
                                         ProxyFactory proxyService,
                                         JavaPropertyValueObjectFactory propertyValueObjectFactory,
                                         boolean annotationSupport,
-                                        String versionSupported) {
+                                        String versionSupported,
+                                        boolean multipleContextSupport) {
         super();
         this.implementation = implementation;
         this.component = component;
         this.propertyValueObjectFactory = propertyValueObjectFactory;
 
-        springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory,
annotationSupport, versionSupported);        
+        springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory,
annotationSupport, versionSupported, multipleContextSupport);        
         
     } // end constructor
 

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
Wed Sep  2 11:57:20 2009
@@ -41,6 +41,7 @@
     private ConfigurationPropertiesExtensionPoint configProperties;
     private boolean annotationSupport;
     private String versionSupported;
+    private boolean multipleContextSupport;
 
     /**
      * Simple constructor
@@ -58,6 +59,7 @@
         }
         annotationSupport = configProperties.isAnnotationSupported();
         versionSupported = configProperties.getSupportedVersion();
+        multipleContextSupport = configProperties.isMultipleContextSupported();
         
         // TODO: could the runtime have a default PropertyValueObjectFactory?
         propertyFactory = new JavaPropertyValueObjectFactory(new MediatorImpl(extensionPoints));
@@ -77,7 +79,8 @@
                                                 proxyFactory, 
                                                 propertyFactory,
                                                 annotationSupport,
-                                                versionSupported);
+                                                versionSupported,
+                                                multipleContextSupport);
     }
 
     /**

Modified: tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java?rev=810466&r1=810465&r2=810466&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
(original)
+++ tuscany/branches/sca-java-1.5.1/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
Wed Sep  2 11:57:20 2009
@@ -31,6 +31,7 @@
 import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -38,6 +39,8 @@
 import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
 import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
 import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader;
+import org.apache.tuscany.sca.implementation.spring.invocation.ConfigurationPropertiesExtensionPoint;
+import org.apache.tuscany.sca.implementation.spring.invocation.DefaultConfigurationPropertiesExtensionPoint;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
 import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.monitor.Problem;
@@ -62,16 +65,24 @@
     private JavaInterfaceFactory javaFactory;
     private PolicyFactory policyFactory;
     private PolicyAttachPointProcessor policyProcessor;
+    private ConfigurationPropertiesExtensionPoint configProperties;
     private Monitor monitor;
-
+    
     private ModelFactoryExtensionPoint factories;
+    private boolean multipleContextSupport;
 
-    public SpringImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor
monitor) {
-        this.factories = modelFactories;
-        this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
-        this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
-        this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+    public SpringImplementationProcessor(ExtensionPointRegistry extensionPoints, Monitor
monitor) {
+        this.factories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
   	
+        this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+        this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+        this.policyFactory = factories.getFactory(PolicyFactory.class);
         this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+                
+        this.configProperties = extensionPoints.getExtensionPoint(ConfigurationPropertiesExtensionPoint.class);
+        if (configProperties == null) {
+        	configProperties = new DefaultConfigurationPropertiesExtensionPoint();
+        }        
+        this.multipleContextSupport = configProperties.isMultipleContextSupported();
         this.monitor = monitor;
     }
 
@@ -196,7 +207,7 @@
 
         /* Load the Spring component type by reading the Spring application context */
         SpringXMLComponentTypeLoader springLoader =
-            new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory);
+            new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory,
multipleContextSupport);
         try {
             // Load the Spring Implementation information from its application context file...
             springLoader.load(springImplementation, resolver);



Mime
View raw message