You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2007/06/09 21:35:33 UTC

svn commit: r545784 - in /incubator/tuscany/java/sca/modules/implementation-spring/src: main/java/org/apache/tuscany/implementation/spring/ main/java/org/apache/tuscany/implementation/spring/xml/ test/java/org/apache/tuscany/implementation/spring/itest...

Author: edwardsmj
Date: Sat Jun  9 12:35:31 2007
New Revision: 545784

URL: http://svn.apache.org/viewvc?view=rev&rev=545784
Log:
Version with working version of Explicit references from Spring application context

Added:
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml   (with props)
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReference.composite
Modified:
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAApplicationContext.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAParentApplicationContext.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProvider.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProviderFactory.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringInvoker.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringModuleActivator.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/xml/SpringXMLComponentTypeLoader.java
    incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitHelloWorld.composite

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAApplicationContext.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAApplicationContext.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAApplicationContext.java Sat Jun  9 12:35:31 2007
@@ -36,7 +36,7 @@
     public SCAApplicationContext(ApplicationContext parent, Resource appXml) {
         super(parent);
         this.appXml = appXml;
-        refresh();
+        //refresh();
     }
 
     protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAParentApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAParentApplicationContext.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAParentApplicationContext.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SCAParentApplicationContext.java Sat Jun  9 12:35:31 2007
@@ -1,9 +1,19 @@
 package org.apache.tuscany.implementation.spring;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
@@ -24,25 +34,64 @@
 class SCAParentApplicationContext implements ApplicationContext {
 	
 	// The Spring implementation for which this is the parent application context
-	private SpringImplementation implementation;
+	private SpringImplementation 	implementation;
+	private RuntimeComponent 		component;
+	private ProxyFactory 			proxyService;
 	
     private static final String[] EMPTY_ARRAY = new String[0];
 	
-	public SCAParentApplicationContext( SpringImplementation implementation ) {
+	public SCAParentApplicationContext( 	RuntimeComponent component, 
+											SpringImplementation implementation,
+											ProxyFactory proxyService ) {
 		this.implementation = implementation;
+		this.component		= component;
+		this.proxyService 	= proxyService;
 	} // end constructor
 
     public Object getBean(String name) throws BeansException {
         return getBean(name, null);
     }
-
-    @SuppressWarnings("unchecked")
+    
+    /**
+     * Get a Bean for a reference..
+     */
     public Object getBean(String name, Class requiredType) throws BeansException {
     	// TODO provide a real implementation of this
     	System.out.println("Spring parent context - getBean called for name: " + name );
-    	return null;
+    	// The expectation is that the requested Bean is a reference from the Spring context
+    	Reference theReference = null;
+    	for ( Reference reference : implementation.getReferences() ) {
+    		if( reference.getName().equals(name) ) { 
+    			theReference = reference;
+    			break;
+    		}
+    	} // end for
+    	if( theReference == null ) 
+    		throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + 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) theReference.getInterfaceContract().getInterface();
+    		requiredType = javaInterface.getJavaClass();
+    	}
+    	// Create and return eturn the proxy for the reference
+    	return getService( requiredType, theReference.getName() );
     } // end method getBean( String, Class )
-
+    
+   
+    private <B> B getService(Class<B> businessInterface, String referenceName) {
+        List<ComponentReference> refs = component.getReferences();
+        for (ComponentReference ref : refs) {
+            if (ref.getName().equals(referenceName)) {
+                RuntimeComponentReference attachPoint = (RuntimeComponentReference)ref;
+                RuntimeWire wire = attachPoint.getRuntimeWires().get(0);
+                return proxyService.createProxy(businessInterface, wire);
+            }
+        }
+        return null;
+    }
+    
     public boolean containsBean(String name) {
     	// TODO
     	System.out.println("Spring parent context - containsBean called for name: " + name );

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProvider.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProvider.java Sat Jun  9 12:35:31 2007
@@ -23,6 +23,7 @@
 public class SpringImplementationProvider implements ImplementationProvider {
     private SpringImplementation 	implementation;
     private RuntimeComponent 		component;
+    private ProxyFactory 			proxyService;
     
     // A Spring application context object
     private AbstractApplicationContext springContext;
@@ -34,12 +35,14 @@
      * @param implementation - the implementation
      */
     public SpringImplementationProvider( RuntimeComponent component,
-                                         SpringImplementation implementation ) {
+                                         SpringImplementation implementation,
+                                         ProxyFactory proxyService ) {
         super();
         this.implementation = implementation;
         this.component 		= component;
+        this.proxyService	= proxyService;
         SCAParentApplicationContext scaParentContext = 
-            	new SCAParentApplicationContext( implementation );
+            	new SCAParentApplicationContext( component, implementation, proxyService );
         springContext = new SCAApplicationContext(scaParentContext, implementation.getResource() );
     } // end constructor
 
@@ -55,8 +58,11 @@
      * 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");
+        System.out.println("SpringImplementationProvider: Spring context started");
     } // end method start()
 
     /**

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProviderFactory.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProviderFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringImplementationProviderFactory.java Sat Jun  9 12:35:31 2007
@@ -1,5 +1,6 @@
 package org.apache.tuscany.implementation.spring;
 
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.provider.ImplementationProvider;
 import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -11,12 +12,15 @@
  */
 public class SpringImplementationProviderFactory implements ImplementationProviderFactory<SpringImplementation> {
 
+	private ProxyFactory proxyService;
+	
 	/**
 	 * Simple constructor
 	 *
 	 */
-    public SpringImplementationProviderFactory() {
+    public SpringImplementationProviderFactory( ProxyFactory proxyService ) {
         super();
+        this.proxyService = proxyService;
     } 
 
     /**
@@ -28,7 +32,7 @@
      */
     public ImplementationProvider createImplementationProvider(RuntimeComponent component,
                                                                SpringImplementation implementation) {
-        return new SpringImplementationProvider( component, implementation );
+        return new SpringImplementationProvider( component, implementation, proxyService );
     }
 
     /**

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringInvoker.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringInvoker.java Sat Jun  9 12:35:31 2007
@@ -26,11 +26,14 @@
  */
 public class SpringInvoker implements Invoker {
 	
-	private Method					theMethod;
+	private Method					theMethod = null;
 	private Object					bean;
 	private SpringBeanElement		beanElement;
 	private boolean					badInvoker = false;
 	
+	private AbstractApplicationContext springContext;
+	private Operation operation;
+	
 	/**
 	 * SpringInvoker constructor
 	 * @param component - the Spring component to invoke
@@ -42,6 +45,9 @@
     					  RuntimeComponentService service, 
     					  Operation operation) {
 
+    	this.springContext 	= springContext;
+    	this.operation 		= operation;
+    	
         // From the component and the service, identify the Spring Bean which is the target
         SpringImplementation theImplementation = (SpringImplementation) component.getImplementation();
         beanElement = theImplementation.getBeanFromService( service.getService() );
@@ -50,7 +56,11 @@
         	badInvoker = true;
         	return;
         }
-        // Now load the class for the bean and get the method relating to the operation....
+
+    } // end constructor SpringInvoker
+    
+    // Lazy-load the method to avoid timing problems with the Spring Context
+    private void setupMethod() {
         try {
         	bean = springContext.getBean( beanElement.getId() );
             Class<?> beanClass = bean.getClass();
@@ -61,9 +71,11 @@
         } catch ( NoSuchMethodException e ) {
         	badInvoker = true;
         }
-    } // end constructor SpringInvoker
+    }
 
     private Object doInvoke(Object payload) throws SpringInvocationException {
+    	if( theMethod == null ) setupMethod();
+    	
     	if( badInvoker ) throw new SpringInvocationException("Spring invoker incorrectly configured");
     	// Invoke the method on the Spring bean using the payload, returning the results
         try {

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringModuleActivator.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/SpringModuleActivator.java Sat Jun  9 12:35:31 2007
@@ -26,6 +26,8 @@
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.invocation.JDKProxyService;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
 import org.apache.tuscany.sca.databinding.Mediator;
@@ -80,6 +82,8 @@
 
         DataBindingExtensionPoint dataBindingRegistry = registry.getExtensionPoint(DataBindingExtensionPoint.class);
                 
+        JDKProxyService proxyFactory = (JDKProxyService) registry.getExtensionPoint(ProxyFactory.class);
+
         // TODO: could the runtime have a default PropertyValueObjectFactory in the registry
         DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
         TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); 
@@ -100,7 +104,7 @@
         
         // Create SpringImplementationFactory and add to provider factories 
         SpringImplementationProviderFactory springImplementationProviderFactory =
-            new SpringImplementationProviderFactory();
+            new SpringImplementationProviderFactory( proxyFactory );
         
         ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
         providerFactories.addProviderFactory(springImplementationProviderFactory);

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/xml/SpringXMLComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/xml/SpringXMLComponentTypeLoader.java?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/xml/SpringXMLComponentTypeLoader.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/implementation/spring/xml/SpringXMLComponentTypeLoader.java Sat Jun  9 12:35:31 2007
@@ -146,6 +146,8 @@
 
             resource = getApplicationContextResource( location, cl );
             implementation.setResource( resource );
+            // The URI is used to uniquely identify the Implementation
+            implementation.setURI( resource.getURL().toString() );
         	// FIXME - need a better way to handle the XMLInputFactory than allocating a new one every time
             XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
             reader = xmlFactory.createXMLStreamReader(resource.getInputStream());
@@ -160,14 +162,14 @@
                     //System.out.println("Spring TypeLoader - found element with name: " + qname.toString());
                     if (SERVICE_ELEMENT.equals(qname)) {
                         SpringSCAServiceElement service = new SpringSCAServiceElement(
-                        		reader.getAttributeValue(SCA_NS, "name"),
-                        		reader.getAttributeValue(SCA_NS, "type"),
-                        		reader.getAttributeValue(SCA_NS, "target") );
+                        		reader.getAttributeValue(null, "name"),
+                        		reader.getAttributeValue(null, "type"),
+                        		reader.getAttributeValue(null, "target") );
                         services.add( service );
                     } else if (REFERENCE_ELEMENT.equals(qname)) {
                         SpringSCAReferenceElement reference = new SpringSCAReferenceElement(
-                        		reader.getAttributeValue(SCA_NS, "name"),
-                        		reader.getAttributeValue(SCA_NS, "type") );
+                        		reader.getAttributeValue(null, "name"),
+                        		reader.getAttributeValue(null, "type") );
                         references.add( reference );
                     } else if (BEAN_ELEMENT.equals(qname)) {
                     	// TODO FIX THIS !!
@@ -178,8 +180,8 @@
                     	beans.add( bean );
                     } else if (PROPERTY_ELEMENT.equals(qname)) {
                     	SpringPropertyElement property = new SpringPropertyElement(
-                    			reader.getAttributeValue(SPRING_NS, "name"),
-                    			reader.getAttributeValue(SPRING_NS, "ref"));
+                    			reader.getAttributeValue(null, "name"),
+                    			reader.getAttributeValue(null, "ref"));
                     	bean.addProperty( property );
                     } // end if
                     break;
@@ -237,7 +239,7 @@
 	    		// Add this service to the Service / Bean map
 	    		String beanName = serviceElement.getTarget();
 	    		for( SpringBeanElement beanElement : beans ) {
-	    			if( beanName == beanElement.getId() ) {
+	    			if( beanName.equals( beanElement.getId() ) ) {
 	    				implementation.setBeanForService( theService, beanElement );
 	    			}
 	    		} // end for

Added: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java?view=auto&rev=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java Sat Jun  9 12:35:31 2007
@@ -0,0 +1,38 @@
+/*
+ * 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.implementation.spring.itests.helloworld;
+
+/**
+ * A simple proxy Java class which implements the HelloWorld interface but which uses
+ * a reference "delegate" to actually provide the HelloWorld service
+ * @author MikeEdwards
+ *
+ */
+public class HelloWorldImpl implements HelloWorld {
+
+	static String hello = "Hello ";
+    
+    public String sayHello(String s) {
+    	// Simply call the reference to satisfy the service request...
+    	System.out.println("HelloWorldImpl - sayHello called");
+        return (hello + s);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java?view=auto&rev=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java Sat Jun  9 12:35:31 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.implementation.spring.itests.helloworld;
+
+/**
+ * A test case of:
+ * 1) A composite containing a component with a Spring implementation which makes
+ * a reference to a second component
+ * 2) The composite has a component with a Java POJO implementation which satisfies the reference
+ * 3) The <implementation.spring.../> element references an application context that
+ * uses an explicit sca:reference element to identify the reference made by the Spring application
+ * 
+ * @author MikeEdwards
+ */
+public class SpringExplicitReferenceTestCase extends AbstractHelloWorldTestCase {
+    // super class does it all getting composite based on this class name
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReferenceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java?view=auto&rev=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java Sat Jun  9 12:35:31 2007
@@ -0,0 +1,39 @@
+package org.apache.tuscany.implementation.spring.itests.mock;
+
+/**
+ * A test Spring bean which provides the HelloWorld service by calling a reference
+ * to provide the content of the response
+ * @author MikeEdwards
+ *
+ */
+
+import org.apache.tuscany.implementation.spring.itests.helloworld.HelloWorld;
+
+public class TestReferenceBean implements HelloWorld {
+	
+	// The reference
+	private HelloWorld bean;
+	
+	// Classic "Hello xxx" response to any input message
+	public String sayHello( String message ) {
+		System.out.println("TestReferenceBean - sayHello called");
+		return( bean.sayHello( message ) );
+	}
+	
+	/**
+	 * Setter for the bean reference
+	 * @param theBean
+	 */
+	public void setBean( HelloWorld theBean ) {
+		this.bean = theBean;
+	}
+	
+	/**
+	 * Getter for the reference
+	 * @return
+	 */
+	public HelloWorld getBean( ) {
+		return this.bean;
+	}
+
+} // end class TestReferenceBean

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/java/org/apache/tuscany/implementation/spring/itests/mock/TestReferenceBean.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml?view=auto&rev=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml (added)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml Sat Jun  9 12:35:31 2007
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:sca="http://www.springframework.org/schema/sca"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">
+
+    <bean id="testBean" class="org.apache.tuscany.implementation.spring.itests.mock.TestReferenceBean">
+        <property name="bean" ref="testReference"/>
+    </bean>
+
+    <sca:reference name="testReference" type="org.apache.tuscany.implementation.spring.itests.helloworld.HelloWorld"/>
+
+</beans>

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/META-INF/sca/SpringExplicitReference-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Modified: incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitHelloWorld.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitHelloWorld.composite?view=diff&rev=545784&r1=545783&r2=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitHelloWorld.composite (original)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitHelloWorld.composite Sat Jun  9 12:35:31 2007
@@ -18,7 +18,7 @@
  * under the License.    
 -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="SpringHelloWorld">
+           name="SpringExplicitHelloWorld">
 
     <component name="ClientComponent">
 		<implementation.java class="org.apache.tuscany.implementation.spring.itests.helloworld.HelloWorldProxy"/>

Added: incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReference.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReference.composite?view=auto&rev=545784
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReference.composite (added)
+++ incubator/tuscany/java/sca/modules/implementation-spring/src/test/resources/org/apache/tuscany/implementation/spring/itests/helloworld/SpringExplicitReference.composite Sat Jun  9 12:35:31 2007
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           name="SpringExplicitReference">
+
+    <component name="ClientComponent">
+        <implementation.spring location="META-INF/sca/SpringExplicitReference-context.xml"/>
+        <reference name="testReference" target="ReferenceComponent"></reference>
+    </component>
+
+    <component name="ReferenceComponent">
+		<implementation.java class="org.apache.tuscany.implementation.spring.itests.helloworld.HelloWorldImpl"/>
+    </component>
+
+</composite>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org