Author: jmarino
Date: Thu Sep 21 21:20:18 2006
New Revision: 448802

URL: http://svn.apache.org/viewvc?view=rev&rev=448802
Log:
references use inbound and outbound chains; additional connection unit tests; 
pass service name to target invoker creation in connector

Added:
    
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
   (with props)
Modified:
    
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
    
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
    
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
    
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
    
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java

Modified: 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
 Thu Sep 21 21:20:18 2006
@@ -47,6 +47,7 @@
 import org.apache.tuscany.spi.model.ComponentType;
 import org.apache.tuscany.spi.model.Implementation;
 import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.WireService;
 
 import 
org.apache.tuscany.core.implementation.system.component.SystemAtomicComponent;
@@ -144,6 +145,10 @@
         bindingBuilders.put(implClass, builder);
     }
 
+    public void register(BindlessBuilder builder) {
+        bindlessBuilder = builder;
+    }
+    
     @SuppressWarnings("unchecked")
     public <B extends Binding> SCAObject build(CompositeComponent parent,
                                                BoundServiceDefinition<B> 
boundServiceDefinition,
@@ -152,7 +157,10 @@
         BindingBuilder<B> bindingBuilder = (BindingBuilder<B>) 
bindingBuilders.get(bindingClass);
         SCAObject object = bindingBuilder.build(parent, 
boundServiceDefinition, deploymentContext);
         if (wireService != null) {
-            wireService.createWires((Service) object, boundServiceDefinition);
+            // wireService.createWires((Service) object, 
boundServiceDefinition);
+            String path = boundServiceDefinition.getTarget().getPath();
+            ServiceContract<?> contract = 
boundServiceDefinition.getServiceContract();
+            wireService.createWires((Service)object, path, contract);
         }
         return object;
     }
@@ -171,16 +179,14 @@
         return object;
     }
 
-    public void register(BindlessBuilder builder) {
-        bindlessBuilder = builder;
-    }
-
     public SCAObject build(CompositeComponent parent,
                            BindlessServiceDefinition serviceDefinition,
                            DeploymentContext deploymentContext) {
         SCAObject object = bindlessBuilder.build(parent, serviceDefinition, 
deploymentContext);
         if (wireService != null) {
-            wireService.createWires((Service) object, serviceDefinition);
+            String path = serviceDefinition.getTarget().getPath();
+            ServiceContract<?> contract = 
serviceDefinition.getServiceContract();
+            wireService.createWires((Service)object, path, contract);
         }
         return object;
     }

Modified: 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
 Thu Sep 21 21:20:18 2006
@@ -40,6 +40,7 @@
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
 import org.apache.tuscany.spi.wire.OutboundInvocationChain;
 import org.apache.tuscany.spi.wire.OutboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
@@ -76,6 +77,7 @@
         CompositeComponent parent = source.getParent();
         if (source instanceof AtomicComponent) {
             AtomicComponent sourceComponent = (AtomicComponent) source;
+            // connect outbound wires for component references to their targets
             for (List<OutboundWire> referenceWires : 
sourceComponent.getOutboundWires().values()) {
                 for (OutboundWire outboundWire : referenceWires) {
                     if (outboundWire instanceof OutboundAutowire) {
@@ -94,45 +96,44 @@
             for (InboundWire inboundWire : 
sourceComponent.getInboundWires().values()) {
                 for (InboundInvocationChain chain : 
inboundWire.getInvocationChains().values()) {
                     Operation<?> operation = chain.getOperation();
-                    TargetInvoker invoker = 
sourceComponent.createTargetInvoker(null, operation);
+                    String serviceName = inboundWire.getServiceName();
+                    TargetInvoker invoker = 
sourceComponent.createTargetInvoker(serviceName, operation);
                     chain.setTargetInvoker(invoker);
                     chain.prepare();
                 }
             }
         } else if (source instanceof Reference) {
             Reference reference = (Reference) source;
-            InboundWire wire = reference.getInboundWire();
-            Map<Operation<?>, InboundInvocationChain> chains = 
wire.getInvocationChains();
-            // for references, no need to have an outbound wire
-            for (InboundInvocationChain chain : chains.values()) {
+            InboundWire inboundWire = reference.getInboundWire();
+            Map<Operation<?>, InboundInvocationChain> inboundChains = 
inboundWire.getInvocationChains();
+            for (InboundInvocationChain chain : inboundChains.values()) {
                 //TODO handle async
-                TargetInvoker invoker = 
reference.createTargetInvoker(wire.getServiceContract(), chain.getOperation());
+                // add target invoker on inbound side
+                TargetInvoker invoker =
+                    
reference.createTargetInvoker(inboundWire.getServiceContract(), 
chain.getOperation());
                 chain.setTargetInvoker(invoker);
                 chain.prepare();
             }
-
-            // Now connect the Reference's outbound wire if it is a composite 
reference
-            if (source instanceof CompositeReference) {
-                CompositeReference compRef = (CompositeReference) source;
-                connect(compRef, compRef.getOutboundWire());
-            }
+            OutboundWire outboundWire = reference.getOutboundWire();
+            // connect the reference's inbound and outbound wires
+            connect(inboundWire, outboundWire, true);
         } else if (source instanceof Service) {
             Service service = (Service) source;
             InboundWire inboundWire = service.getInboundWire();
             OutboundWire outboundWire = service.getOutboundWire();
             // connect the outbound service wire to the target
             connect(service, outboundWire);
-            // services have inbound and outbound wires
             // NB: this connect must be done after the outbound service chain 
is connected to its target above
             if (!(source instanceof CompositeService)) {
+                //REVIEW JFM: why is this special for composites?
                 connect(inboundWire, outboundWire, true);
             }
         }
     }
 
     public void connect(InboundWire sourceWire,
-                            OutboundWire targetWire,
-                            boolean optimizable) throws BuilderConfigException 
{
+                        OutboundWire targetWire,
+                        boolean optimizable) throws BuilderConfigException {
         if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
@@ -155,11 +156,20 @@
         }
     }
 
+    /**
+     * Connects the source wire to a corresponding target wire
+     *
+     * @param source      the owner of the source wire
+     * @param target      the owner of the target wire
+     * @param sourceWire  the source wire to connect
+     * @param targetWire  the target wire to connect to
+     * @param optimizable true if the wire connection can be optimized
+     */
     public void connect(SCAObject source,
-                            SCAObject target,
-                            OutboundWire sourceWire,
-                            InboundWire targetWire,
-                            boolean optimizable) {
+                        SCAObject target,
+                        OutboundWire sourceWire,
+                        InboundWire targetWire,
+                        boolean optimizable) {
         if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
@@ -196,7 +206,7 @@
                     invoker = component.createAsyncTargetInvoker(targetWire, 
operation);
                 } else {
                     Operation<?> inboundOperation = 
inboundChain.getOperation();
-                    invoker = component.createTargetInvoker(null, 
inboundOperation);
+                    invoker = 
component.createTargetInvoker(sourceWire.getTargetName().getPortName(), 
inboundOperation);
                 }
             } else if (target instanceof Reference) {
                 Reference reference = (Reference) target;
@@ -204,7 +214,8 @@
                     // Notice that for bound references we only use async 
target invokers for callback operations
                     invoker = reference.createAsyncTargetInvoker(sourceWire, 
operation);
                 } else {
-                    invoker = 
reference.createTargetInvoker(targetWire.getServiceContract(), 
inboundChain.getOperation());
+                    invoker =
+                        
reference.createTargetInvoker(targetWire.getServiceContract(), 
inboundChain.getOperation());
                 }
             } else if (target instanceof CompositeService) {
                 CompositeService compServ = (CompositeService) target;
@@ -258,15 +269,16 @@
     public void connect(OutboundInvocationChain sourceChain,
                         InboundInvocationChain targetChain,
                         TargetInvoker invoker) {
-        if (targetChain.getHeadInterceptor() == null) {
-            BuilderConfigException e = new BuilderConfigException("No chain 
handler or interceptor for operation");
+        Interceptor headInterceptor = targetChain.getHeadInterceptor();
+        if (headInterceptor == null) {
+            BuilderConfigException e = new BuilderConfigException("No 
interceptor for operation");
             e.setIdentifier(targetChain.getOperation().getName());
             throw e;
         }
         if (!(sourceChain.getTailInterceptor() instanceof InvokerInterceptor
-            && targetChain.getHeadInterceptor() instanceof 
InvokerInterceptor)) {
+            && headInterceptor instanceof InvokerInterceptor)) {
             // check that we do not have the case where the only interceptors 
are invokers since we just need one
-            sourceChain.setTargetInterceptor(targetChain.getHeadInterceptor());
+            sourceChain.setTargetInterceptor(headInterceptor);
         }
         sourceChain.prepare(); //FIXME prepare should be moved out
         sourceChain.setTargetInvoker(invoker);
@@ -292,7 +304,7 @@
      * @throws BuilderConfigException
      */
     private void connect(SCAObject source,
-                             OutboundWire sourceWire) throws 
BuilderConfigException {
+                         OutboundWire sourceWire) throws 
BuilderConfigException {
         assert sourceWire.getTargetName() != null : "Wire target name was 
null";
         QualifiedName targetName = sourceWire.getTargetName();
         CompositeComponent parent = source.getParent();
@@ -362,7 +374,6 @@
 
     private void checkIfWireable(OutboundWire sourceWire, InboundWire 
targetWire) {
         if (wireService == null) {
-            // FIXME: [rfeng] wireService won't be injected for the system 
connector?
             Class<?> sourceInterface = 
sourceWire.getServiceContract().getInterfaceClass();
             Class<?> targetInterface = 
targetWire.getServiceContract().getInterfaceClass();
             if (!sourceInterface.isAssignableFrom(targetInterface)) {

Modified: 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
 Thu Sep 21 21:20:18 2006
@@ -35,7 +35,6 @@
 import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.component.WorkContext;
 import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
-import org.apache.tuscany.spi.model.BindlessServiceDefinition;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
 import org.apache.tuscany.spi.model.ComponentType;
@@ -207,32 +206,37 @@
         }
     }
 
-    public <T> void createWires(Reference reference, ServiceContract<?> 
contract) {
-        InboundWire wire = new InboundWireImpl();
-        wire.setServiceContract(contract);
-        wire.setContainer(reference);
+    public void createWires(Reference reference, ServiceContract<?> contract) {
+        InboundWire inboundWire = new InboundWireImpl();
+        inboundWire.setServiceContract(contract);
+        inboundWire.setContainer(reference);
         for (Operation<?> operation : contract.getOperations().values()) {
             InboundInvocationChain chain = createInboundChain(operation);
+            inboundWire.addInvocationChain(operation, chain);
+        }
+        OutboundWire outboundWire = new OutboundWireImpl();
+        outboundWire.setServiceContract(contract);
+        outboundWire.setContainer(reference);
+        for (Operation<?> operation : contract.getOperations().values()) {
+            OutboundInvocationChain chain = createOutboundChain(operation);
             chain.addInterceptor(new InvokerInterceptor());
-            wire.addInvocationChain(operation, chain);
+            outboundWire.addInvocationChain(operation, chain);
         }
-        // Notice that we skip wire.setCallbackReferenceName
-        // First, an inbound wire's callbackReferenceName is only retrieved by 
JavaAtomicComponent
+
+        // Notice that we skip inboundWire.setCallbackReferenceName
+        // First, an inbound inboundWire's callbackReferenceName is only 
retrieved by JavaAtomicComponent
         // to create a callback injector based on the callback reference 
member; a composite reference
         // should not need to do that
         // Second, a reference definition does not have a callback reference 
name like a service
         // definition does
-        reference.setInboundWire(wire);
+        reference.setInboundWire(inboundWire);
+        reference.setOutboundWire(outboundWire);
     }
 
     public void createWires(Service service, BoundServiceDefinition<?> def) {
         createWires(service, def.getTarget().getPath(), 
def.getServiceContract());
     }
 
-    public void createWires(Service service, BindlessServiceDefinition def) {
-        createWires(service, def.getTarget().getPath(), 
def.getServiceContract());
-    }
-
     public OutboundWire createWire(ReferenceTarget reference, 
ReferenceDefinition def) {
         //TODO multiplicity
         if (reference.getTargets().size() != 1) {
@@ -283,7 +287,7 @@
         return wire;
     }
 
-    private <T> void createWires(Service service, String targetName, 
ServiceContract<?> contract) {
+    public void createWires(Service service, String targetName, 
ServiceContract<?> contract) {
         InboundWire inboundWire = new InboundWireImpl();
         OutboundWire outboundWire = new OutboundWireImpl();
         inboundWire.setServiceContract(contract);

Added: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java?view=auto&rev=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
 (added)
+++ 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
 Thu Sep 21 21:20:18 2006
@@ -0,0 +1,306 @@
+package org.apache.tuscany.core.builder;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.wire.BridgingInterceptor;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectorImplTestCase extends TestCase {
+
+    private Connector connector = new ConnectorImpl();
+
+    public void testConnectReferenceWires() {
+        // create the wire contract, operation
+        ServiceContract contract = new JavaServiceContract(String.class);
+        Operation<Type> operation = new Operation<Type>("bar", null, null, 
null);
+
+        // create source and target interceptors
+        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(headInterceptor);
+
+        // create the inbound wire and chain
+        InboundInvocationChain inboundChain = 
EasyMock.createMock(InboundInvocationChain.class);
+        
EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        inboundChain.addInterceptor(EasyMock.isA(BridgingInterceptor.class));
+        inboundChain.setTargetInvoker(null);
+        inboundChain.prepare();
+        EasyMock.replay(inboundChain);
+        Map<Operation<?>, InboundInvocationChain> inboundChains = new 
HashMap<Operation<?>, InboundInvocationChain>();
+        inboundChains.put(operation, inboundChain);
+        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+        
EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        
EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
+        EasyMock.replay(inboundWire);
+
+        OutboundInvocationChain outboundChain = 
EasyMock.createMock(OutboundInvocationChain.class);
+        
EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+        EasyMock.replay(outboundChain);
+        Map<Operation<?>, OutboundInvocationChain> outboundChains =
+            new HashMap<Operation<?>, OutboundInvocationChain>();
+        outboundChains.put(operation, outboundChain);
+        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+        
EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(outboundWire.getTargetName()).andReturn(new 
QualifiedName("target/FooService")).anyTimes();
+        
EasyMock.expect((outboundWire.getInvocationChains())).andReturn(outboundChains).anyTimes();
+        EasyMock.replay(outboundWire);
+
+        Reference reference = EasyMock.createMock(Reference.class);
+        EasyMock.expect(reference.getParent()).andReturn(null);
+        EasyMock.expect(reference.createTargetInvoker(contract, 
operation)).andReturn(null);
+        EasyMock.expect(reference.getInboundWire()).andReturn(inboundWire);
+        EasyMock.expect(reference.getOutboundWire()).andReturn(outboundWire);
+        EasyMock.replay(reference);
+
+        connector.connect(reference);
+
+        EasyMock.verify(reference);
+        EasyMock.verify(inboundWire);
+        EasyMock.verify(outboundWire);
+        EasyMock.verify(inboundChain);
+        EasyMock.verify(outboundChain);
+
+    }
+
+    public void testConnectServiceWires() {
+        // create the wire contract, operation
+        ServiceContract contract = new JavaServiceContract(String.class);
+        Operation<Type> operation = new Operation<Type>("bar", null, null, 
null);
+
+        // create source and target interceptors
+        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(headInterceptor);
+        Interceptor tailInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(tailInterceptor);
+
+        // create the inbound wire and chain for the target
+        InboundInvocationChain targetChain = 
EasyMock.createMock(InboundInvocationChain.class);
+        
EasyMock.expect(targetChain.getOperation()).andReturn(operation).atLeastOnce();
+        
EasyMock.expect(targetChain.getHeadInterceptor()).andReturn(headInterceptor);
+        targetChain.prepare();
+        EasyMock.replay(targetChain);
+        Map<Operation<?>, InboundInvocationChain> targetChains = new 
HashMap<Operation<?>, InboundInvocationChain>();
+        targetChains.put(operation, targetChain);
+        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+        
EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+        
EasyMock.expect(targetWire.getInvocationChains()).andReturn(targetChains);
+        targetWire.getSourceCallbackInvocationChains("source");
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(targetWire);
+
+        // create the target
+        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
+        target.getInboundWire(EasyMock.eq("FooService"));
+        EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce();
+        target.createTargetInvoker(EasyMock.eq("FooService"), 
EasyMock.eq(operation));
+        EasyMock.expectLastCall().andReturn(null);
+        EasyMock.replay(target);
+
+        // create the parent composite
+        CompositeComponent parent = 
EasyMock.createMock(CompositeComponent.class);
+        EasyMock.expect(parent.getChild("target")).andReturn(target);
+        EasyMock.replay(parent);
+
+        // create the inbound wire and chain for the source service
+        InboundInvocationChain inboundChain = 
EasyMock.createMock(InboundInvocationChain.class);
+        
EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        inboundChain.addInterceptor(EasyMock.isA(BridgingInterceptor.class));
+        inboundChain.setTargetInvoker(null);
+        EasyMock.replay(inboundChain);
+        Map<Operation<?>, InboundInvocationChain> inboundChains = new 
HashMap<Operation<?>, InboundInvocationChain>();
+        inboundChains.put(operation, inboundChain);
+        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+        
EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        
EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
+        EasyMock.replay(inboundWire);
+
+        // create the outbound wire and chain for the source service
+        OutboundInvocationChain outboundChain = 
EasyMock.createMock(OutboundInvocationChain.class);
+        
EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tailInterceptor);
+        
EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+        outboundChain.setTargetInterceptor(headInterceptor);
+        outboundChain.prepare();
+        outboundChain.setTargetInvoker(null);
+        EasyMock.expect(outboundChain.getOperation()).andReturn(operation);
+        EasyMock.replay(outboundChain);
+        Map<Operation<?>, OutboundInvocationChain> outboundChains =
+            new HashMap<Operation<?>, OutboundInvocationChain>();
+        outboundChains.put(operation, outboundChain);
+        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+        outboundWire.getTargetCallbackInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        
EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(outboundWire.getTargetName()).andReturn(new 
QualifiedName("target/FooService")).anyTimes();
+        
EasyMock.expect((outboundWire.getInvocationChains())).andReturn(outboundChains).anyTimes();
+        EasyMock.replay(outboundWire);
+
+        // create the service
+        Service service = EasyMock.createMock(Service.class);
+        EasyMock.expect(service.getName()).andReturn("source");
+        EasyMock.expect(service.getParent()).andReturn(parent).atLeastOnce();
+        
EasyMock.expect(service.getInboundWire()).andReturn(inboundWire).atLeastOnce();
+        EasyMock.expect(service.getScope()).andReturn(Scope.COMPOSITE);
+        EasyMock.expect(service.getOutboundWire()).andReturn(outboundWire);
+        EasyMock.replay(service);
+
+        connector.connect(service);
+
+        EasyMock.verify(service);
+        EasyMock.verify(inboundWire);
+        EasyMock.verify(outboundWire);
+        EasyMock.verify(inboundChain);
+        EasyMock.verify(outboundChain);
+    }
+
+    /**
+     * Verifies connecting a wire from an atomic component to a target atomic 
component with one synchronous operation
+     */
+    public void testConnectAtomicComponentToAtomicComponentSyncWire() throws 
Exception {
+        // create the wire contractm, operation
+        ServiceContract contract = new JavaServiceContract(String.class);
+        Operation<Type> operation = new Operation<Type>("bar", null, null, 
null);
+
+        // create source and target interceptors
+        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(headInterceptor);
+        Interceptor tailInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(tailInterceptor);
+
+        // create the inbound wire and chain
+        InboundInvocationChain inboundChain = 
EasyMock.createMock(InboundInvocationChain.class);
+        
EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        
EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+        EasyMock.replay(inboundChain);
+        Map<Operation<?>, InboundInvocationChain> inboundChains = new 
HashMap<Operation<?>, InboundInvocationChain>();
+        inboundChains.put(operation, inboundChain);
+        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+        
EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+        
EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
+        targetWire.getSourceCallbackInvocationChains("source");
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(targetWire);
+
+        // create the target
+        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
+        target.getInboundWire(EasyMock.eq("FooService"));
+        EasyMock.expectLastCall().andReturn(targetWire);
+        target.createTargetInvoker(EasyMock.eq("FooService"), 
EasyMock.eq(operation));
+        EasyMock.expectLastCall().andReturn(null);
+        EasyMock.replay(target);
+
+        // create the parent composite
+        CompositeComponent parent = 
EasyMock.createMock(CompositeComponent.class);
+        EasyMock.expect(parent.getChild("target")).andReturn(target);
+        EasyMock.replay(parent);
+
+        // create the outbound wire and chain from the source component
+        OutboundInvocationChain outboundChain = 
EasyMock.createMock(OutboundInvocationChain.class);
+        
EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tailInterceptor);
+        
EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        outboundChain.setTargetInterceptor(EasyMock.eq(headInterceptor));
+        outboundChain.setTargetInvoker(null);
+        outboundChain.prepare();
+        EasyMock.replay(outboundChain);
+        Map<Operation<?>, OutboundInvocationChain> outboundChains =
+            new HashMap<Operation<?>, OutboundInvocationChain>();
+        outboundChains.put(operation, outboundChain);
+        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+        
EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(outboundWire.getTargetName()).andReturn(new 
QualifiedName("target/FooService")).anyTimes();
+        
EasyMock.expect((outboundWire.getInvocationChains())).andReturn(outboundChains).anyTimes();
+        outboundWire.getTargetCallbackInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(outboundWire);
+        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, 
List<OutboundWire>>();
+        List<OutboundWire> list = new ArrayList<OutboundWire>();
+        list.add(outboundWire);
+        outboundWires.put("fooService", list);
+
+        // create the source
+        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(source.getScope()).andReturn(Scope.MODULE);
+        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
+        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
+        EasyMock.expect(source.getName()).andReturn("source");
+        source.getInboundWires();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(source);
+
+        connector.connect(source);
+        EasyMock.verify(headInterceptor);
+        EasyMock.verify(tailInterceptor);
+        EasyMock.verify(outboundWire);
+        EasyMock.verify(targetWire);
+        EasyMock.verify(outboundChain);
+        EasyMock.verify(inboundChain);
+        EasyMock.verify(source);
+        EasyMock.verify(target);
+    }
+
+    public void testConnectInboundAtomicComponentWires() {
+
+        // create the wire contractm, operation
+        ServiceContract contract = new JavaServiceContract(String.class);
+        Operation<Type> operation = new Operation<Type>("bar", null, null, 
null);
+
+        // create the inbound wire and chain
+        InboundInvocationChain chain = 
EasyMock.createMock(InboundInvocationChain.class);
+        
EasyMock.expect(chain.getOperation()).andReturn(operation).atLeastOnce();
+        chain.setTargetInvoker(null);
+        chain.prepare();
+        EasyMock.replay(chain);
+        Map<Operation<?>, InboundInvocationChain> inboundChains = new 
HashMap<Operation<?>, InboundInvocationChain>();
+        inboundChains.put(operation, chain);
+        InboundWire wire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(wire.getServiceName()).andReturn("FooService");
+        
EasyMock.expect(wire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(wire.getInvocationChains()).andReturn(inboundChains);
+        EasyMock.replay(wire);
+
+        Map<String, InboundWire> wires = new HashMap<String, InboundWire>();
+        wires.put("FooService", wire);
+
+        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(source.getParent()).andReturn(null);
+        source.getOutboundWires();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        source.getInboundWires();
+        EasyMock.expectLastCall().andReturn(wires);
+        source.createTargetInvoker(EasyMock.eq("FooService"), 
EasyMock.eq(operation));
+        EasyMock.expectLastCall().andReturn(null);
+        EasyMock.replay(source);
+
+        connector.connect(source);
+
+        EasyMock.verify(source);
+        EasyMock.verify(wire);
+        EasyMock.verify(chain);
+
+    }
+}

Propchange: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
 Thu Sep 21 21:20:18 2006
@@ -30,10 +30,10 @@
 public interface Connector {
 
     /**
-     * Connects the given artifact to a target in its composite
+     * Connects the given source's wires to corresponding wires to a target. 
Wires are connected by bridging invocation
+     * chains.
      *
-     * @param source the source artifact to context, i.e. a 
<code>Service</code>, <code>Component</code>, or
-     *               <code>Reference</code>
+     * @param source the source, i.e. a <code>Service</code>, 
<code>Component</code>, or <code>Reference</code>
      */
     void connect(SCAObject source);
 

Modified: 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
 Thu Sep 21 21:20:18 2006
@@ -60,7 +60,7 @@
                      DataType<List<DataType<T>>> inputType,
                      DataType<T> outputType,
                      List<DataType<T>> faultTypes) {
-        this(name, inputType, outputType, faultTypes, true, null);
+        this(name, inputType, outputType, faultTypes, false, null);
     }
 
     /**

Modified: 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java?view=diff&rev=448802&r1=448801&r2=448802
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
 Thu Sep 21 21:20:18 2006
@@ -21,8 +21,6 @@
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.Service;
-import org.apache.tuscany.spi.model.BindlessServiceDefinition;
-import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ReferenceDefinition;
@@ -119,7 +117,16 @@
      * @param reference the reference
      * @param contract  the model artifact representing the service contract 
for the reference
      */
-    <T> void createWires(Reference reference, ServiceContract<?> contract);
+    void createWires(Reference reference, ServiceContract<?> contract);
+
+    /**
+     * Creates wires for a service and injects them on the service
+     *
+     * @param service    the service
+     * @param targetName the target nane
+     * @param contract   the service contract
+     */
+    void createWires(Service service, String targetName, ServiceContract<?> 
contract);
 
     /**
      * Creates wires for a service and injects them on the service
@@ -127,7 +134,7 @@
      * @param service the service
      * @param def     the model artifact representing the service
      */
-    void createWires(Service service, BoundServiceDefinition<?> def);
+    //void createWires(Service service, BoundServiceDefinition<?> def);
 
     /**
      * Creates wires for a composite service and injects them on the service
@@ -135,25 +142,21 @@
      * @param service the service
      * @param def     the model artifact representing the service
      */
-    void createWires(Service service, BindlessServiceDefinition def);
+    //void createWires(Service service, BindlessServiceDefinition def);
 
     /**
-     * Check the compatiblity of the source and the target service 
contracts.<p>
-     * A wire may only connect a source to a target if the target implements 
an interface that is compatible with the
-     * interface required by the source. The source and the target are 
compatible if:
-     * <p>
-     * <ol>
-     * <li>the source interface and the target interface MUST either both be 
remotable or they are both local
+     * Check the compatiblity of the source and the target service 
contracts.<p> A wire may only connect a source to a
+     * target if the target implements an interface that is compatible with 
the interface required by the source. The
+     * source and the target are compatible if:
+     * <p/>
+     * <ol> <li>the source interface and the target interface MUST either both 
be remotable or they are both local
      * <li>the methods on the target interface MUST be the same as or be a 
superset of the methods in the interface
-     * specified on the source
-     * <li>compatibility for the individual method is defined as compatibility 
of the signature, that is method name,
-     * input types, and output types MUST BE the same.
-     * <li>the order of the input and output types also MUST BE the same.
-     * <li>the set of Faults and Exceptions expected by the source MUST BE the 
same or be a superset of those specified
-     * by the service.
-     * <li>other specified attributes of the two interfaces MUST match, 
including Scope and Callback interface
-     * </ol>
-     *
+     * specified on the source <li>compatibility for the individual method is 
defined as compatibility of the signature,
+     * that is method name, input types, and output types MUST BE the same. 
<li>the order of the input and output types
+     * also MUST BE the same. <li>the set of Faults and Exceptions expected by 
the source MUST BE the same or be a
+     * superset of those specified by the service. <li>other specified 
attributes of the two interfaces MUST match,
+     * including Scope and Callback interface </ol>
+     * <p/>
      * <p>Please note this test is not symetric: isWireable(A, B) does NOT 
imply that isWireable(B, A)
      *
      * @param source The source service contract



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to