You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2009/04/30 18:19:22 UTC

svn commit: r770312 - in /tuscany/java/sca/modules: implementation-spring-runtime/ implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/im...

Author: antelder
Date: Thu Apr 30 16:19:21 2009
New Revision: 770312

URL: http://svn.apache.org/viewvc?rev=770312&view=rev
Log:
Start to separate the tuscany and spring code into descrete modules with no references to Spring classes in the implementation-spring module and no references to Tuscany classes in the implementation-spring-runtime module. Work in progress, compiles cleanly but the tests don't run but then they didn't run before this commit either

Added:
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
Removed:
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SCAParentApplicationContext.java
Modified:
    tuscany/java/sca/modules/implementation-spring-runtime/pom.xml
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
    tuscany/java/sca/modules/implementation-spring/pom.xml
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java

Modified: tuscany/java/sca/modules/implementation-spring-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/pom.xml?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/pom.xml (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/pom.xml Thu Apr 30 16:19:21 2009
@@ -29,37 +29,7 @@
     <name>Apache Tuscany SCA Spring Implementation Runtime Model</name>
 
     <dependencies>
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-assembly</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-interface</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-assembly-xml</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>        
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-contribution</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-sca-api</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java-runtime</artifactId>
-            <version>2.0-SNAPSHOT</version>
-        </dependency>
-               
+
         <!-- Spring dependencies... -->    
         <dependency>
             <groupId>org.springframework</groupId>

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java Thu Apr 30 16:19:21 2009
@@ -18,30 +18,30 @@
  */
 package org.apache.tuscany.sca.implementation.spring.processor;
 
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
 
-import org.springframework.util.Assert;
 import org.springframework.beans.BeanUtils;
-import org.springframework.util.ReflectionUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.config.BeanPostProcessor;
-
-import org.oasisopen.sca.annotation.ComponentName;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
 
 public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
 
-    private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+//    private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+    private Class<? extends Annotation> componentNameAnnotationType;
     
-    private RuntimeComponent component;
+    private String componentName;
     
-    public ComponentNameAnnotationProcessor (RuntimeComponent component) {
-        this.component = component;
+    public ComponentNameAnnotationProcessor (Class<? extends Annotation> componentNameAnnotationType,String componentName) {
+        this.componentNameAnnotationType = componentNameAnnotationType;
+        this.componentName = componentName;
     }
     
     /**
@@ -103,7 +103,7 @@
                     ReflectionUtils.makeAccessible(field);
                     
                     if (field.getType().getName().equals("java.lang.String")) {
-                        Object nameObj = component.getName();   
+                        Object nameObj = componentName;   
                         if (nameObj != null)
                             ReflectionUtils.setField(field, bean, nameObj);
                     } else {
@@ -133,7 +133,7 @@
                     PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);                    
                     
                     if (pd.getPropertyType().getName().equals("java.lang.String")) {
-                        Object nameObj = component.getName();                    
+                        Object nameObj = componentName;                    
                         if (nameObj != null) {
                             try {                                                       
                                 pd.getWriteMethod().invoke(bean, new Object[] { nameObj });

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java Thu Apr 30 16:19:21 2009
@@ -18,27 +18,24 @@
  */
 package org.apache.tuscany.sca.implementation.spring.processor;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Constructor;
 import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
+import java.lang.reflect.Constructor;
 
-import org.springframework.util.Assert;
 import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
 
 public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
 
-    private Class<? extends Annotation> constructorAnnotationType 
-                                            = org.oasisopen.sca.annotation.Constructor.class;
+//    private Class<? extends Annotation> constructorAnnotationType 
+//    = org.oasisopen.sca.annotation.Constructor.class;
+    private Class<? extends Annotation> constructorAnnotationType;
     
     private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
     
-    public ConstructorAnnotationProcessor () {
-        // Default constructor.
+    public ConstructorAnnotationProcessor (Class<? extends Annotation> annotation) {
+        this.constructorAnnotationType = annotation;
     }
     
     /**

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java Thu Apr 30 16:19:21 2009
@@ -19,18 +19,22 @@
 package org.apache.tuscany.sca.implementation.spring.processor;
 
 import java.lang.annotation.Annotation;
-import org.oasisopen.sca.annotation.Init;
-import org.oasisopen.sca.annotation.Destroy;
+
 import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
-import org.springframework.util.Assert;
 
 public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {    
     
     private static final long serialVersionUID = 0;
     
-    private Class<? extends Annotation> initAnnotationType = Init.class;
-
-    private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+//    private Class<? extends Annotation> initAnnotationType = Init.class;
+//    private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+    private Class<? extends Annotation> initAnnotationType;
+    private Class<? extends Annotation> destroyAnnotationType;
+    
+    public InitDestroyAnnotationProcessor(Class<? extends Annotation> initAnnotationType, Class<? extends Annotation> destroyAnnotationType) {
+        this.initAnnotationType = initAnnotationType;
+        this.destroyAnnotationType = destroyAnnotationType;
+    }
     
     /**
      * Gets init annotation type.

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java Thu Apr 30 16:19:21 2009
@@ -18,38 +18,32 @@
  */
 package org.apache.tuscany.sca.implementation.spring.processor;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.beans.PropertyDescriptor;
 import java.lang.annotation.Annotation;
-import java.util.List;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
-import org.springframework.util.Assert;
-import org.springframework.beans.BeanUtils;
-import org.springframework.util.ReflectionUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
 
-import org.oasisopen.sca.annotation.Property;
-import org.apache.tuscany.sca.assembly.ComponentProperty;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import com.sun.xml.internal.bind.v2.runtime.property.Property;
 
 public class PropertyAnnotationProcessor implements BeanPostProcessor {
 
-    private Class<? extends Annotation> propertyAnnotationType = Property.class;
-    
-    private RuntimeComponent component;
+//    private Class<? extends Annotation> propertyAnnotationType = Property.class;
+    private Class<? extends Annotation> propertyAnnotationType;
     
-    private JavaPropertyValueObjectFactory propertyFactory;
+//    private RuntimeComponent component;
+//    
+//    private JavaPropertyValueObjectFactory propertyFactory;
     
-    public PropertyAnnotationProcessor (JavaPropertyValueObjectFactory propertyFactory, 
-                                        RuntimeComponent component) {
-        this.propertyFactory = propertyFactory;
-        this.component = component;
+    public PropertyAnnotationProcessor (Class<? extends Annotation> propertyAnnotationType) {
+        this.propertyAnnotationType = propertyAnnotationType;
+//        this.propertyFactory = propertyFactory;
+//        this.component = component;
     }
 
     /**
@@ -97,62 +91,62 @@
 
         ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
             public void doWith(Method method) {
-                //Annotation annotation = method.getAnnotation(getPropertyAnnotationType());                
-                Property annotation = (Property) method.getAnnotation(getPropertyAnnotationType());
-                
-                if (annotation != null) {
-                    if (Modifier.isStatic(method.getModifiers())) {
-                        throw new IllegalStateException("Property annotation is not supported on static methods");
-                    }
-                    
-                    if (Modifier.isPrivate(method.getModifiers())) {
-                        throw new IllegalStateException("Property annotation is not supported on private methods");
-                    }
-
-                    if (method.getParameterTypes().length == 0) {
-                        throw new IllegalStateException("Property annotation requires at least one argument: " + method);
-                    }
-                    
-                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
-                    if (pd != null) {
-                        String propName = annotation.name();
-                        if ("".equals(propName)) {
-                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), pd.getName()));
-                        } else {
-                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), propName));
-                        }
-                    }
-                }
+//                //Annotation annotation = method.getAnnotation(getPropertyAnnotationType());                
+//                Property annotation = (Property) method.getAnnotation(getPropertyAnnotationType());
+//                
+//                if (annotation != null) {
+//                    if (Modifier.isStatic(method.getModifiers())) {
+//                        throw new IllegalStateException("Property annotation is not supported on static methods");
+//                    }
+//                    
+//                    if (Modifier.isPrivate(method.getModifiers())) {
+//                        throw new IllegalStateException("Property annotation is not supported on private methods");
+//                    }
+//
+//                    if (method.getParameterTypes().length == 0) {
+//                        throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+//                    }
+//                    
+//                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+//                    if (pd != null) {
+//                        String propName = annotation.name();
+//                        if ("".equals(propName)) {
+//                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), pd.getName()));
+//                        } else {
+//                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), propName));
+//                        }
+//                    }
+//                }
             }
         });
         
         ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
             public void doWith(Field field) {
                 //Annotation annotation = field.getAnnotation(getPropertyAnnotationType());
-                Property annotation = (Property) field.getAnnotation(getPropertyAnnotationType());
-                
-                if (annotation != null) {
-                    if (Modifier.isStatic(field.getModifiers())) {
-                        throw new IllegalStateException("Property annotation is not supported on static fields");
-                    }
-                    
-                    if (Modifier.isPrivate(field.getModifiers())) {
-                        throw new IllegalStateException("Property annotation is not supported on private fields");
-                    }
-
-                    ReflectionUtils.makeAccessible(field);
-                    
-                    Object propertyObj = null;
-                    String propName = annotation.name();
-                    if ("".equals(propName)) {
-                        propertyObj = getPropertyObj(field.getType(), field.getName());                        
-                    } else {
-                        propertyObj = getPropertyObj(field.getType(), propName);
-                    }
-                    
-                    if (propertyObj != null)
-                        ReflectionUtils.setField(field, bean, propertyObj);
-                }
+//                Property annotation = (Property) field.getAnnotation(getPropertyAnnotationType());
+//                
+//                if (annotation != null) {
+//                    if (Modifier.isStatic(field.getModifiers())) {
+//                        throw new IllegalStateException("Property annotation is not supported on static fields");
+//                    }
+//                    
+//                    if (Modifier.isPrivate(field.getModifiers())) {
+//                        throw new IllegalStateException("Property annotation is not supported on private fields");
+//                    }
+//
+//                    ReflectionUtils.makeAccessible(field);
+//                    
+//                    Object propertyObj = null;
+//                    String propName = annotation.name();
+//                    if ("".equals(propName)) {
+//                        propertyObj = getPropertyObj(field.getType(), field.getName());                        
+//                    } else {
+//                        propertyObj = getPropertyObj(field.getType(), propName);
+//                    }
+//                    
+//                    if (propertyObj != null)
+//                        ReflectionUtils.setField(field, bean, propertyObj);
+//                }
             }
         });
     }
@@ -164,15 +158,15 @@
         
         Object propertyObj = null;
         
-        List<ComponentProperty> props = component.getProperties();
-        for (ComponentProperty prop : props) {
-            if (prop.getName().equals(name)) {
-                // On finding the property, create a factory for it and create a Bean using
-                // the factory
-                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
-                propertyObj = factory.getInstance();
-            } // end if
-        } // end for        
+//        List<ComponentProperty> props = component.getProperties();
+//        for (ComponentProperty prop : props) {
+//            if (prop.getName().equals(name)) {
+//                // On finding the property, create a factory for it and create a Bean using
+//                // the factory
+//                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
+//                propertyObj = factory.getInstance();
+//            } // end if
+//        } // end for        
         
         return propertyObj;
     }

Modified: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java Thu Apr 30 16:19:21 2009
@@ -18,30 +18,28 @@
  */
 package org.apache.tuscany.sca.implementation.spring.processor;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.beans.PropertyDescriptor;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.naming.Reference;
 
-import org.springframework.util.Assert;
-import org.springframework.beans.BeanUtils;
-import org.springframework.util.ReflectionUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.config.BeanPostProcessor;
-
-import org.oasisopen.sca.annotation.Reference;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
 
 public class ReferenceAnnotationProcessor implements BeanPostProcessor {
 
-    private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+//    private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+    private Class<? extends Annotation> referenceAnnotationType;
     
-    private RuntimeComponent component;
+//    private RuntimeComponent component;
     
-    public ReferenceAnnotationProcessor (RuntimeComponent component) {
-        this.component = component;
+    public ReferenceAnnotationProcessor (Class<? extends Annotation> referenceAnnotationType, Object component) {
+        this.referenceAnnotationType = referenceAnnotationType;
     }
     
     /**
@@ -90,61 +88,61 @@
         ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
             public void doWith(Method method) {
                 //Annotation annotation = method.getAnnotation(getReferenceAnnotationType());                
-                Reference annotation = (Reference) method.getAnnotation(getReferenceAnnotationType());
-                
-                if (annotation != null) {
-                    if (Modifier.isStatic(method.getModifiers())) {
-                        throw new IllegalStateException("Reference annotation is not supported on static methods");
-                    }
-                    
-                    if (Modifier.isPrivate(method.getModifiers())) {
-                        throw new IllegalStateException("Reference annotation is not supported on private methods");
-                    }
-
-                    if (method.getParameterTypes().length == 0) {
-                        throw new IllegalStateException("Reference annotation requires at least one argument: " + method);
-                    }
-                    
-                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
-                    if (pd != null) {
-                        String refName = annotation.name();
-                        if ("".equals(refName)) {
-                            injectReference(bean, pd, pd.getName());
-                        } else {
-                            injectReference(bean, pd, refName);
-                        }
-                    }
-                }
+//                Reference annotation = (Reference) method.getAnnotation(getReferenceAnnotationType());
+//                
+//                if (annotation != null) {
+//                    if (Modifier.isStatic(method.getModifiers())) {
+//                        throw new IllegalStateException("Reference annotation is not supported on static methods");
+//                    }
+//                    
+//                    if (Modifier.isPrivate(method.getModifiers())) {
+//                        throw new IllegalStateException("Reference annotation is not supported on private methods");
+//                    }
+//
+//                    if (method.getParameterTypes().length == 0) {
+//                        throw new IllegalStateException("Reference annotation requires at least one argument: " + method);
+//                    }
+//                    
+//                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+//                    if (pd != null) {
+//                        String refName = annotation.name();
+//                        if ("".equals(refName)) {
+//                            injectReference(bean, pd, pd.getName());
+//                        } else {
+//                            injectReference(bean, pd, refName);
+//                        }
+//                    }
+//                }
             }
         });
         
         ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
             public void doWith(Field field) {
                 //Annotation annotation = field.getAnnotation(getReferenceAnnotationType());                
-                Reference annotation = (Reference) field.getAnnotation(getReferenceAnnotationType());
-                
-                if (annotation != null) {
-                    if (Modifier.isStatic(field.getModifiers())) {
-                        throw new IllegalStateException("Reference annotation is not supported on static fields");
-                    }
-                    
-                    if (Modifier.isPrivate(field.getModifiers())) {
-                        throw new IllegalStateException("Reference annotation is not supported on private fields");
-                    }
-
-                    ReflectionUtils.makeAccessible(field);
-                    
-                    Object referenceObj = null;
-                    String refName = annotation.name();
-                    if ("".equals(refName)) {
-                        referenceObj = component.getComponentContext().getService(field.getType(), field.getName());
-                    } else {
-                        referenceObj = component.getComponentContext().getService(field.getType(), refName);
-                    }                        
-                    
-                    if (referenceObj != null)
-                        ReflectionUtils.setField(field, bean, referenceObj);
-                }
+//                Reference annotation = (Reference) field.getAnnotation(getReferenceAnnotationType());
+//                
+//                if (annotation != null) {
+//                    if (Modifier.isStatic(field.getModifiers())) {
+//                        throw new IllegalStateException("Reference annotation is not supported on static fields");
+//                    }
+//                    
+//                    if (Modifier.isPrivate(field.getModifiers())) {
+//                        throw new IllegalStateException("Reference annotation is not supported on private fields");
+//                    }
+//
+//                    ReflectionUtils.makeAccessible(field);
+//                    
+//                    Object referenceObj = null;
+//                    String refName = annotation.name();
+//                    if ("".equals(refName)) {
+//                        referenceObj = component.getComponentContext().getService(field.getType(), field.getName());
+//                    } else {
+//                        referenceObj = component.getComponentContext().getService(field.getType(), refName);
+//                    }                        
+//                    
+//                    if (referenceObj != null)
+//                        ReflectionUtils.setField(field, bean, referenceObj);
+//                }
             }
         });
     }
@@ -154,15 +152,15 @@
      */
     public void injectReference(Object bean, PropertyDescriptor pd, String name) {
                
-        Object referenceObj = component.getComponentContext().getService(pd.getPropertyType(), name);
-        
-        if (referenceObj != null) {
-            try {                                                       
-                pd.getWriteMethod().invoke(bean, new Object[] { referenceObj });
-            } catch (Throwable e) {
-                throw new FatalBeanException("Problem injecting reference:  " + e.getMessage(), e);
-            }
-        }
+//        Object referenceObj = component.getComponentContext().getService(pd.getPropertyType(), name);
+//        
+//        if (referenceObj != null) {
+//            try {                                                       
+//                pd.getWriteMethod().invoke(bean, new Object[] { referenceObj });
+//            } catch (Throwable e) {
+//                throw new FatalBeanException("Problem injecting reference:  " + e.getMessage(), e);
+//            }
+//        }
     }
     
     /**

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java?rev=770312&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java Thu Apr 30 16:19:21 2009
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.runtime.context;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.core.io.Resource;
+
+/**
+ * A Spring ParentApplicationContext for a given Spring Implementation
+ *
+ * The Parent application context is responsible for handling those entities within a Spring
+ * application context that actually belong to SCA rather than to Spring.  The principal things
+ * are Properties and References.  These may be present either through explicit <sca:property/>
+ * and <sca:reference/> elements in the application context or they may be implicit through
+ * unresolved Spring bean <property.../> elements.  In either case, it is the Parent application
+ * context that must provide Spring beans that correspond to the property or reference, as derived
+ * from the SCA composite in which the Spring application context is an implementation.
+ *
+ * @version $Rev: 511195 $ $Date: 2007-02-24 02:29:46 +0000 (Sat, 24 Feb 2007) $
+ */
+class SCAParentApplicationContext implements ApplicationContext {
+
+    // The Spring implementation for which this is the parent application context
+    private SpringImplementationStub implementation;
+
+    private static final String[] EMPTY_ARRAY = new String[0];
+
+    public SCAParentApplicationContext(SpringImplementationStub implementation) {
+        this.implementation = implementation;
+    } // end constructor
+
+    public Object getBean(String name) throws BeansException {
+        return getBean(name, (Class) null);
+    }
+
+    /**
+     * Get a Bean for a reference or for a property.
+     *
+     * @param name - the name of the Bean required
+     * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+     * @return Object - a Bean which matches the requested bean
+     */
+    public Object getBean(String name, Class requiredType) throws BeansException {
+        return implementation.getBean(name, requiredType);
+    } // end method getBean( String, Class )
+
+    public Object getBean(String name, Object[] args) throws BeansException {
+         return getBean(name, ((Class)null));
+    }
+
+    public boolean containsBean(String name) {
+        // TODO
+        System.out.println("Spring parent context - containsBean called for name: " + name);
+        return false;
+    }
+
+    public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+        // TODO
+        return false;
+    }
+
+    public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Class getType(String name) throws NoSuchBeanDefinitionException {
+        return null;
+    }
+
+    public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+        return EMPTY_ARRAY;
+    }
+
+    public ApplicationContext getParent() {
+        return null;
+    }
+
+    public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+        return null;
+    }
+
+    public String getId() {
+          return this.toString();
+    }
+
+    public String getDisplayName() {
+        return implementation.getURI();
+    }
+
+    public long getStartupDate() {
+        return 0;
+    }
+
+    public boolean containsBeanDefinition(String beanName) {
+        return false;
+    }
+
+    public int getBeanDefinitionCount() {
+        return 0;
+    }
+
+    public String[] getBeanDefinitionNames() {
+        return new String[0];
+    }
+
+    public String[] getBeanNamesForType(Class type) {
+        return new String[0];
+    }
+
+    public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+        return new String[0];
+    }
+
+    public Map getBeansOfType(Class type) throws BeansException {
+        return null;
+    }
+
+    public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException {
+        return null;
+    }
+
+    public boolean isPrototype(String theString) {
+        return false;
+    }
+
+    public BeanFactory getParentBeanFactory() {
+        return null;
+    }
+
+    public boolean containsLocalBean(String name) {
+        return false;
+    }
+
+    public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+        return null;
+    }
+
+    public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+        return null;
+    }
+
+    public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+        return null;
+    }
+
+    public void publishEvent(ApplicationEvent event) {
+
+    }
+
+    public Resource[] getResources(String locationPattern) throws IOException {
+        return new Resource[0];
+    }
+
+    public Resource getResource(String location) {
+        return null;
+    }
+
+    public ClassLoader getClassLoader() {
+        // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+        // resource loading mechanism is exposed right now.
+        return this.getClass().getClassLoader();
+    }
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java?rev=770312&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java Thu Apr 30 16:19:21 2009
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.implementation.spring.runtime.context;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.processor.ConstructorAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.InitDestroyAnnotationProcessor;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.ManagedList;
+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;
+
+/**
+ * This is the runtime side tie for the corresponding tuscany side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextStub class
+ * in the implementation-spring module for what the stub does. 
+ */
+public class SpringContextTie {
+
+    private AbstractApplicationContext springContext;
+    
+    public SpringContextTie(SpringImplementationStub implementation, URL resource) {
+        SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
+        springContext = createApplicationContext(scaParentContext, resource);        
+    }
+
+    public void start() {
+        // Do refresh here to ensure that Spring Beans are not touched before the SCA config process is complete...
+        springContext.refresh();
+        springContext.start();
+    }
+
+    public void close() {
+        springContext.close();
+        if (springContext instanceof GenericApplicationContext) {
+            springContext.stop();
+        }
+    }
+
+    /**
+     * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+     */
+//    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("~");
+                                                }
+                                        }
+                                        listValues = (values.toString()).split("~");                                    
+                                }
+                        }
+                        
+                        if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {                                                                   
+                                appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);                                   
+                                //includeAnnotationProcessors(appContext.getBeanFactory());
+                                        return appContext;
+                        } else {
+                                appContext = new FileSystemXmlApplicationContext(listValues, false, scaParentContext);                                  
+                                //includeAnnotationProcessors(appContext.getBeanFactory());
+                                        return appContext;
+                        }
+                }               
+        }
+        
+        // use the generic application context as default 
+        includeAnnotationProcessors(beanFactory);
+        appContext = new GenericApplicationContext(beanFactory, scaParentContext);
+        return appContext;
+    }
+
+//    public Object getBean(String id) throws SpringInvocationException {
+//        try {
+//            return springContext.getBean(beanElement.getId());
+//        } catch (BeansException e) {
+//            throw new SpringInvocationException(e);
+//    }
+
+    /**
+     * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+     */
+    private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
+        
+        // Processor to deal with @Init and @Destroy SCA Annotations
+//        BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
+//        beanFactory.addBeanPostProcessor(initDestroyProcessor);
+
+// TODO: implement passing the component and property factory        
+//        // Processor to deal with @Reference SCA Annotations
+//        BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
+//        beanFactory.addBeanPostProcessor(referenceProcessor);
+//        
+//        // Processor to deal with @Property SCA Annotations
+//        BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(propertyValueObjectFactory, component);
+//        beanFactory.addBeanPostProcessor(propertyProcessor);
+//        
+//        // Processor to deal with @ComponentName SCA Annotations
+//        BeanPostProcessor componentNameProcessor = new ComponentNameAnnotationProcessor(component);
+//        beanFactory.addBeanPostProcessor(componentNameProcessor);
+        
+        // Processor to deal with @Constructor SCA Annotations
+//        BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
+//        beanFactory.addBeanPostProcessor(constructorProcessor);         
+    }
+
+}

Added: tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java?rev=770312&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java (added)
+++ tuscany/java/sca/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java Thu Apr 30 16:19:21 2009
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.implementation.spring.runtime.context;
+
+import java.lang.reflect.Method;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+/**
+ * This is the runtime side stub for the corresponding Tuscany-side stub class.
+ * It enables the Spring code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationTie class
+ * in the implementation-spring module for what the tie does. 
+ */
+public class SpringImplementationStub {
+
+    Object tie;
+    Method getURI;
+    Method getBean;
+    
+    public SpringImplementationStub(Object tie) {
+        this.tie = tie;
+        Class<?> tieClass = tie.getClass();
+        try {
+            getURI = tieClass.getMethod("getURI", new Class<?>[]{});
+            getBean = tieClass.getMethod("getBean", new Class<?>[]{String.class, Class.class});
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    public String getURI() {
+        try {
+
+            return (String)getURI.invoke(tie);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Get a Bean for a reference or for a property.
+     *
+     * @param name - the name of the Bean required
+     * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+     * @return Object - a Bean which matches the requested bean
+     */
+    public Object getBean(String name, Class<?> requiredType) throws BeansException {
+        try {
+
+            Object bean = getBean.invoke(tie, new Object[] {name, requiredType});
+            if (bean == null) {
+                throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+            }
+            return bean;
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+}

Modified: tuscany/java/sca/modules/implementation-spring/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/pom.xml?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/pom.xml (original)
+++ tuscany/java/sca/modules/implementation-spring/pom.xml Thu Apr 30 16:19:21 2009
@@ -64,23 +64,6 @@
             <artifactId>tuscany-implementation-spring-runtime</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
-        
-        <!-- Spring dependencies... -->    
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-            <version>2.5.5</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-            <version>2.5.5</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-            <version>2.5.5</version>
-        </dependency>
-          
+                  
     </dependencies>
 </project>

Added: tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java?rev=770312&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java (added)
+++ tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java Thu Apr 30 16:19:21 2009
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.implementation.spring.invocation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side stub for the corresponding runtime tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextTie class
+ * in the implementation-spring-runtime module for what the tie does. 
+ */
+public class SpringContextStub {
+
+    private Object tie;
+    private Method startMethod;
+    private Method closeMethod;
+    private Method getBeanMethod;
+
+    public SpringContextStub(RuntimeComponent component,
+                               SpringImplementation implementation,
+                               ProxyFactory proxyService,
+                               JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+
+        initTie(component, implementation, propertyValueObjectFactory);        
+
+    }
+
+    private void initTie(RuntimeComponent component,
+                         SpringImplementation implementation,
+                         JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+
+        // TODO: what class loader to use?
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+        try {
+
+            Class<?> stubClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringImplementationStub", true, cl);
+            Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[]{Object.class});
+            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});
+            this.tie = tieConstructor.newInstance(stub,null);
+            
+            this.startMethod = tieClass.getMethod("start");
+            this.closeMethod = tieClass.getMethod("close");
+            this.getBeanMethod = tieClass.getMethod("getBean");
+
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (SecurityException e) {
+            throw new RuntimeException(e);
+        } catch (NoSuchMethodException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException(e);
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void start() {
+        try {
+            startMethod.invoke(tie);
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void close() {
+        try {
+            closeMethod.invoke(tie);
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Object getBean(String id) throws SpringInvocationException {
+        try {
+
+            return getBeanMethod.invoke(tie, id);
+
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Modified: tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java (original)
+++ tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java Thu Apr 30 16:19:21 2009
@@ -18,34 +18,14 @@
  */
 package org.apache.tuscany.sca.implementation.spring.invocation;
 
-import java.util.List;
-import java.util.Iterator;
-
 import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.provider.ImplementationProvider;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
-import org.apache.tuscany.sca.implementation.spring.processor.InitDestroyAnnotationProcessor;
-import org.apache.tuscany.sca.implementation.spring.processor.ReferenceAnnotationProcessor;
-import org.apache.tuscany.sca.implementation.spring.processor.PropertyAnnotationProcessor;
-import org.apache.tuscany.sca.implementation.spring.processor.ConstructorAnnotationProcessor;
-import org.apache.tuscany.sca.implementation.spring.processor.ComponentNameAnnotationProcessor;
-import org.springframework.beans.factory.config.BeanPostProcessor; 
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConstructorArgumentValues;
-import org.springframework.beans.factory.config.TypedStringValue;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-import org.springframework.core.io.UrlResource;
 
 /**
  * A provider class for runtime Spring implementation instances
@@ -55,7 +35,7 @@
     private RuntimeComponent component;
     
     // A Spring application context object
-    private AbstractApplicationContext springContext;
+    private SpringContextStub springContext;
     
     private SpringImplementation implementation;
     
@@ -75,13 +55,8 @@
         this.implementation = implementation;
         this.component = component;
         this.propertyValueObjectFactory = propertyValueObjectFactory;
-        
-        SCAParentApplicationContext scaParentContext =
-            new SCAParentApplicationContext(component, implementation, proxyService, propertyValueObjectFactory);
-        //springContext = new SCAApplicationContext(scaParentContext, implementation.getResource());        
-        
-        XmlBeanFactory beanFactory = new XmlBeanFactory(new UrlResource(implementation.getResource()));
-        springContext = createApplicationContext(beanFactory, scaParentContext);        
+
+        springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory);        
         
     } // end constructor
 
@@ -97,104 +72,14 @@
      * Start this Spring implementation instance
      */
     public void start() {
-        // Do refresh here to ensure that Spring Beans are not touched before the SCA config process 
-        // is complete...
-        springContext.refresh();
         springContext.start();
-        // System.out.println("SpringImplementationProvider: Spring context started");
-    } // end method start()
+    }
 
     /**
      * Stop this implementation instance
      */
     public void stop() {
-        // TODO - complete
     	springContext.close();
-    	if (springContext instanceof GenericApplicationContext)
-    		springContext.stop();
-        //System.out.println("SpringImplementationProvider: Spring context stopped");
-    } // end method stop
-    
-    
-    /**
-     * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
-     */
-    private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
-    	
-    	// Processor to deal with @Init and @Destroy SCA Annotations
-    	BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
-        beanFactory.addBeanPostProcessor(initDestroyProcessor);
-        
-        // Processor to deal with @Reference SCA Annotations
-        BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
-        beanFactory.addBeanPostProcessor(referenceProcessor);
-        
-        // Processor to deal with @Property SCA Annotations
-        BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(propertyValueObjectFactory, component);
-        beanFactory.addBeanPostProcessor(propertyProcessor);
-        
-        // Processor to deal with @ComponentName SCA Annotations
-        BeanPostProcessor componentNameProcessor = new ComponentNameAnnotationProcessor(component);
-        beanFactory.addBeanPostProcessor(componentNameProcessor);
-        
-        // Processor to deal with @Constructor SCA Annotations
-        BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
-        beanFactory.addBeanPostProcessor(constructorProcessor);    	
     }
-    
-    
-    /**
-     * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
-     */
-    private AbstractApplicationContext createApplicationContext(XmlBeanFactory beanFactory,
-    															SCAParentApplicationContext scaParentContext) {
-    	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("~");
-	    					}
-	    				}
-	    				listValues = (values.toString()).split("~");	    				
-	    			}
-    			}
-    			
-    			if (beanClassName.indexOf(".ClassPathXmlApplicationContext") != -1) {    				    				
-    				appContext = new ClassPathXmlApplicationContext(listValues, false, scaParentContext);    				
-    				//includeAnnotationProcessors(appContext.getBeanFactory());
-					return appContext;
-    			} else {
-    				appContext = new FileSystemXmlApplicationContext(listValues, false, scaParentContext);    				
-    				//includeAnnotationProcessors(appContext.getBeanFactory());
-					return appContext;
-    			}
-    		}    		
-    	}
-    	
-    	// use the generic application context as default 
-        includeAnnotationProcessors(beanFactory);
-        appContext = new GenericApplicationContext(beanFactory, scaParentContext);
-        return appContext;
-    }
-    
+
 } // end class SpringImplementationProvider

Added: tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java?rev=770312&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java (added)
+++ tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java Thu Apr 30 16:19:21 2009
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.implementation.spring.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side tie for the corresponding runtime stub class.
+ * It enables the Sping code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationStub class
+ * in the implementation-spring-runtime module for what the stub does. 
+ */
+public class SpringImplementationTie {
+
+    private SpringImplementation implementation;
+    private RuntimeComponent component;
+    private JavaPropertyValueObjectFactory propertyFactory;
+    
+    public SpringImplementationTie(SpringImplementation implementation, RuntimeComponent component, JavaPropertyValueObjectFactory propertyFactory) {
+        this.implementation = implementation;
+        this.component = component;
+        this.propertyFactory = propertyFactory;
+    }
+    
+    public String getURI() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /**
+     * Method to create a Java Bean for a Property value
+     * @param <B> the class type of the Bean
+     * @param requiredType - a Class object for the required type
+     * @param name - the Property name
+     * @return - a Bean of the specified property, with value set
+     */
+    private <B> B getPropertyBean(Class requiredType, String name) {
+        B propertyObject = null;
+        // Get the component's list of properties
+        List<ComponentProperty> props = component.getProperties();
+        for (ComponentProperty prop : props) {
+            if (prop.getName().equals(name)) {
+                // On finding the property, create a factory for it and create a Bean using
+                // the factory
+                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
+                propertyObject = (B)factory.getInstance();
+            } // end if
+        } // end for
+
+        return propertyObject;
+    }
+
+    /**
+     * Creates a proxy Bean for a reference
+     * @param <B> the Business interface type for the reference
+     * @param businessInterface - the business interface as a Class
+     * @param referenceName - the name of the Reference
+     * @return an Bean of the type defined by <B>
+     */
+    private <B> B getService(Class<B> businessInterface, String referenceName) {
+        return component.getComponentContext().getService(businessInterface, referenceName);
+    }
+
+    /**
+     * Get a Bean for a reference or for a property.
+     *
+     * @param name - the name of the Bean required
+     * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+     * @return Object - a Bean which matches the requested bean
+     */
+    public Object getBean(String name, Class requiredType) {
+        System.out.println("Spring parent context - getBean called for name: " + name);
+        // The expectation is that the requested Bean is either a reference or a property
+        // from the Spring context
+        for (Reference reference : implementation.getReferences()) {
+            if (reference.getName().equals(name)) {
+                // Extract the Java interface for the reference (it can't be any other interface type
+                // for a Spring application context)
+                if (requiredType == null) {
+                    JavaInterface javaInterface = (JavaInterface)reference.getInterfaceContract().getInterface();
+                    requiredType = javaInterface.getJavaClass();
+                }
+                // Create and return the proxy for the reference
+                return getService(requiredType, reference.getName());
+            } // end if
+        } // end for
+
+        // For a property, get the name and the required Java type and create a Bean
+        // of that type with the value inserted.
+        for (Property property : implementation.getProperties()) {
+            if (property.getName().equals(name)) {
+                if (requiredType == null) {
+                    // The following code only deals with a subset of types and was superceded
+                    // by the information from the implementation (which uses Classes as found
+                    // in the Spring implementation itself.
+                    //requiredType = JavaXMLMapper.getJavaType( property.getXSDType() );
+                    requiredType = implementation.getPropertyClass(name);
+                }
+                return getPropertyBean(requiredType, property.getName());
+            } // end if
+        } // end for
+        // TODO: NoSuchBeanException
+        throw new RuntimeException("Unable to find Bean with name " + name);
+
+    } // end method getBean( String, Class )
+
+}

Modified: tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java?rev=770312&r1=770311&r2=770312&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java (original)
+++ tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java Thu Apr 30 16:19:21 2009
@@ -29,8 +29,6 @@
 import org.apache.tuscany.sca.invocation.Message;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.springframework.beans.BeansException;
-import org.springframework.context.support.AbstractApplicationContext;
 
 /**
  * Initial implementation of a Spring bean invoker
@@ -43,7 +41,7 @@
     private SpringBeanElement beanElement;
     private boolean badInvoker = false;
 
-    private AbstractApplicationContext springContext;
+    private SpringContextStub springContext;
     private Operation operation;
 
     /**
@@ -53,7 +51,7 @@
      * @param operation - the operation to invoke
      */
     public SpringInvoker(RuntimeComponent component,
-                         AbstractApplicationContext springContext,
+                         SpringContextStub springContext,
                          RuntimeComponentService service,
                          Operation operation) {
 
@@ -78,8 +76,6 @@
             Class<?> beanClass = bean.getClass();
             theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
             //System.out.println("SpringInvoker - found method " + theMethod.getName() );
-        } catch (BeansException e) {
-            throw new SpringInvocationException(e);
         } catch (NoSuchMethodException e) {
         	throw new SpringInvocationException(e);
         }