You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/05/22 01:48:50 UTC

svn commit: r408527 - in /incubator/tuscany/sandbox/jboynes/sca: core2/src/main/java/org/apache/tuscany/core/builder/ core2/src/main/java/org/apache/tuscany/core/wire/ core2/src/main/java/org/apache/tuscany/core/wire/jdk/ core2/src/test/java/org/apache...

Author: jmarino
Date: Sun May 21 16:48:50 2006
New Revision: 408527

URL: http://svn.apache.org/viewvc?rev=408527&view=rev
Log:
bug fix for when an invocation only has a response handler; more testcases

Modified:
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKSourceWire.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKTargetWire.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/InvocationErrorTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerTestCase.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceContextExtension.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceContextExtension.java
    incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java Sun May 21 16:48:50 2006
@@ -115,7 +115,7 @@
                 throw e;
             }
             // if handler is configured, add that
-            if (targetChain.getRequestHandlers() != null) {
+            if (targetChain.getRequestHandlers() != null || targetChain.getResponseHandlers() != null) {
                 sourceChain.setTargetRequestChannel(new MessageChannelImpl(targetChain
                         .getRequestHandlers()));
                 sourceChain.setTargetResponseChannel(new MessageChannelImpl(targetChain

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java Sun May 21 16:48:50 2006
@@ -14,6 +14,7 @@
 package org.apache.tuscany.core.wire;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 
 import org.apache.tuscany.spi.wire.SourceInvocationChain;
 import org.apache.tuscany.spi.wire.Interceptor;
@@ -63,13 +64,18 @@
     }
 
     public void build() {
-        if (requestHandlers != null && targetInterceptorChainHead != null) {
+        if ((requestHandlers != null || responseHandlers != null) && targetInterceptorChainHead != null) {
             // on target-side, connect existing handlers and interceptors
             MessageHandler messageDispatcher = new MessageDispatcher(targetInterceptorChainHead);
+            if (requestHandlers == null) {
+                // case where there is only a response handler
+                requestHandlers = new ArrayList<MessageHandler>();
+            }
+
             requestHandlers.add(messageDispatcher);
         }
 
-        if (requestHandlers != null) {
+        if (requestHandlers != null || responseHandlers != null) {
             MessageChannel requestChannel = new MessageChannelImpl(requestHandlers);
             MessageChannel responseChannel = new MessageChannelImpl(responseHandlers);
             Interceptor channelInterceptor = new RequestResponseInterceptor(requestChannel, targetRequestChannel,

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java Sun May 21 16:48:50 2006
@@ -37,13 +37,13 @@
 public class JDKInvocationHandler implements WireInvocationHandler {
 
     /*
-     * an association of an operation to configuration holder. The holder contains the master wire configuration
-     * and a locale clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
+     * an association of an operation to chain holder. The holder contains the master wire chain
+     * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
      * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers
      * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
-     * is not cacheable, the master associated with the wire configuration will be used.
+     * is not cacheable, the master associated with the wire chains will be used.
      */
-    private Map<Method, ConfigHolder> configuration;
+    private Map<Method, ChainHolder> chains;
 
     public JDKInvocationHandler() {
     }
@@ -53,13 +53,13 @@
      */
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
         Interceptor headInterceptor = null;
-        ConfigHolder holder = configuration.get(method);
+        ChainHolder holder = chains.get(method);
         if (holder == null) {
             TargetException e = new TargetException("Operation not configured");
             e.setIdentifier(method.getName());
             throw e;
         }
-        InvocationChain config = holder.config;
+        InvocationChain config = holder.chain;
         if (config != null) {
             headInterceptor = config.getHeadInterceptor();
         }
@@ -101,7 +101,6 @@
             msg.setBody(args);
             // dispatch the wire down the chain and get the response
             Message resp = headInterceptor.invoke(msg);
-
             Object body = resp.getBody();
             if (body instanceof Throwable) {
                 throw (Throwable) body;
@@ -110,24 +109,24 @@
         }
     }
 
-    public void setConfiguration(Map<Method, ? extends InvocationChain> configuration) {
-        this.configuration = new HashMap<Method, ConfigHolder>(configuration.size());
-        for (Map.Entry<Method, ? extends InvocationChain> entry : configuration.entrySet()) {
-            this.configuration.put(entry.getKey(), new ConfigHolder(entry.getValue()));
+    public void setChains(Map<Method, ? extends InvocationChain> invocationChains) {
+        this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
+        for (Map.Entry<Method, ? extends InvocationChain> entry : invocationChains.entrySet()) {
+            this.chains.put(entry.getKey(), new ChainHolder(entry.getValue()));
         }
     }
 
     /**
-     * A holder used to associate an wire configuration with a local copy of a target invoker that was
-     * previously cloned from the configuration master
+     * A holder used to associate an wire chain with a local copy of a target invoker that was
+     * previously cloned from the chain master
      */
-    private class ConfigHolder {
+    private class ChainHolder {
 
-        InvocationChain config;
+        InvocationChain chain;
         TargetInvoker cachedInvoker;
 
-        public ConfigHolder(InvocationChain config) {
-            this.config = config;
+        public ChainHolder(InvocationChain config) {
+            this.chain = config;
         }
 
     }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKSourceWire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKSourceWire.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKSourceWire.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKSourceWire.java Sun May 21 16:48:50 2006
@@ -46,7 +46,7 @@
             return targetWire.getTargetService();
         }
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(invocationChains);
+        handler.setChains(invocationChains);
         return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), businessInterfaces, handler);
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKTargetWire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKTargetWire.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKTargetWire.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKTargetWire.java Sun May 21 16:48:50 2006
@@ -26,7 +26,7 @@
     @SuppressWarnings("unchecked")
     public T getTargetService() throws TargetException {
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(invocationChains);
+        handler.setChains(invocationChains);
         return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), businessInterfaces, handler);
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java Sun May 21 16:48:50 2006
@@ -19,20 +19,21 @@
 import org.apache.tuscany.core.mock.component.SimpleTarget;
 import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
 import org.apache.tuscany.core.mock.context.MockAtomicContext;
+import org.apache.tuscany.core.mock.wire.MockHandler;
 import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
 import org.apache.tuscany.core.wire.SourceInvocationChainImpl;
 import org.apache.tuscany.core.wire.TargetInvocationChainImpl;
-import org.apache.tuscany.core.wire.InvokerInterceptor;
 import org.apache.tuscany.core.wire.jdk.JDKSourceWire;
 import org.apache.tuscany.core.wire.jdk.JDKTargetWire;
 import org.apache.tuscany.spi.QualifiedName;
 import org.apache.tuscany.spi.context.ScopeContext;
 import org.apache.tuscany.spi.context.WorkContext;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.MessageHandler;
 import org.apache.tuscany.spi.wire.SourceInvocationChain;
 import org.apache.tuscany.spi.wire.SourceWire;
 import org.apache.tuscany.spi.wire.TargetWire;
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.MessageHandler;
 
 /**
  * @version $$Rev$$ $$Date$$
@@ -46,16 +47,16 @@
         ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
         scopeContext.start();
 
-        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext,null,null,null);
-        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext,null,null,null);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null, null, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
         for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
             TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
-            connector.connect((SourceWire<SimpleTarget>)sourceWire, targetWire, targetContext,false);
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
         }
 
         scopeContext.onEvent(new ModuleStart(this, null));
         SimpleSource source = sourceContext.getService();
-        assertEquals("foo",source.getTarget().echo("foo"));
+        assertEquals("foo", source.getTarget().echo("foo"));
         scopeContext.onEvent(new ModuleStop(this, null));
         scopeContext.stop();
     }
@@ -64,6 +65,7 @@
     /**
      * Verifies an invocation with a single source interceptor
      */
+    @SuppressWarnings("unchecked")
     public void testSourceInterceptor() throws Exception {
         ConnectorImpl connector = new ConnectorImpl();
         WorkContext workContext = new WorkContextImpl();
@@ -73,24 +75,273 @@
         MockSyncInterceptor interceptor = new MockSyncInterceptor();
         List<Interceptor> interceptors = new ArrayList<Interceptor>();
         interceptors.add(interceptor);
-        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext,interceptors,null,null);
-        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext,null,null,null);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, interceptors, null, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
         for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
             TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
-            connector.connect((SourceWire<SimpleTarget>)sourceWire, targetWire, targetContext,false);
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
         }
 
         scopeContext.onEvent(new ModuleStart(this, null));
-        assertEquals(0,interceptor.getCount());
+        assertEquals(0, interceptor.getCount());
         SimpleSource source = sourceContext.getService();
-        assertEquals("foo",source.getTarget().echo("foo"));
-        assertEquals(1,interceptor.getCount());
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, interceptor.getCount());
         scopeContext.onEvent(new ModuleStop(this, null));
         scopeContext.stop();
     }
 
+    /**
+     * Verifies an invocation with a single target interceptor
+     */
+    @SuppressWarnings("unchecked")
+    public void testTargetInterceptor() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
 
+        MockSyncInterceptor interceptor = new MockSyncInterceptor();
+        List<Interceptor> interceptors = new ArrayList<Interceptor>();
+        interceptors.add(interceptor);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null, null, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, interceptors, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
 
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, interceptor.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, interceptor.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a source and target interceptor
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceTargetInterceptor() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+        List<Interceptor> sourceInterceptors = new ArrayList<Interceptor>();
+        sourceInterceptors.add(sourceInterceptor);
+        MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+        List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
+        targetInterceptors.add(targetInterceptor);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, sourceInterceptors, null, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, targetInterceptors, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, sourceInterceptor.getCount());
+        assertEquals(0, targetInterceptor.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, sourceInterceptor.getCount());
+        assertEquals(1, targetInterceptor.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a source interceptor and a request handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceInterceptorSourceRequestHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockSyncInterceptor interceptor = new MockSyncInterceptor();
+        List<Interceptor> interceptors = new ArrayList<Interceptor>();
+        interceptors.add(interceptor);
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, interceptors, handlers, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, interceptor.getCount());
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, handler.getCount());
+        assertEquals(1, interceptor.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a source interceptor and response handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceInterceptorSourceResponseHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockSyncInterceptor interceptor = new MockSyncInterceptor();
+        List<Interceptor> interceptors = new ArrayList<Interceptor>();
+        interceptors.add(interceptor);
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, interceptors, null, handlers);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, interceptor.getCount());
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, handler.getCount());
+        assertEquals(1, interceptor.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a source interceptor, request handler, and response handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceInterceptorSourceRequestResponseHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockSyncInterceptor interceptor = new MockSyncInterceptor();
+        List<Interceptor> interceptors = new ArrayList<Interceptor>();
+        interceptors.add(interceptor);
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, interceptors, handlers, handlers);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, interceptor.getCount());
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(2, handler.getCount());
+        assertEquals(1, interceptor.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a source request handler and response handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceRequestResponseHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null, handlers, handlers);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(2, handler.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a single source request handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceRequestHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null, handlers, null);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, handler.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
+
+    /**
+     * Verifies an invocation with a single source response handler
+     */
+    @SuppressWarnings("unchecked")
+    public void testSourceResponseHandler() throws Exception {
+        ConnectorImpl connector = new ConnectorImpl();
+        WorkContext workContext = new WorkContextImpl();
+        ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+        scopeContext.start();
+
+        MockHandler handler = new MockHandler();
+        List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+        handlers.add(handler);
+        MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null,null, handlers);
+        MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, null, null, null);
+        for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+            TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+            connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+        }
+
+        scopeContext.onEvent(new ModuleStart(this, null));
+        assertEquals(0, handler.getCount());
+        SimpleSource source = sourceContext.getService();
+        assertEquals("foo", source.getTarget().echo("foo"));
+        assertEquals(1, handler.getCount());
+        scopeContext.onEvent(new ModuleStop(this, null));
+        scopeContext.stop();
+    }
 
     private MockAtomicContext<SimpleSource> setupSource(ScopeContext scopeContext, List<Interceptor> interceptors,
                                                         List<MessageHandler> requestHandlers,
@@ -109,17 +360,17 @@
         sourceWire.setReferenceName("target");
         sourceWire.setTargetName(new QualifiedName("target/Target"));
         SourceInvocationChain chain = new SourceInvocationChainImpl(echo);
-        if (interceptors != null){
+        if (interceptors != null) {
             for (Interceptor interceptor : interceptors) {
                 chain.addInterceptor(interceptor);
             }
         }
-        if(requestHandlers != null){
+        if (requestHandlers != null) {
             for (MessageHandler handler : requestHandlers) {
                 chain.addRequestHandler(handler);
             }
         }
-        if(responseHandlers != null){
+        if (responseHandlers != null) {
             for (MessageHandler handler : responseHandlers) {
                 chain.addResponseHandler(handler);
             }
@@ -132,7 +383,7 @@
 
     private MockAtomicContext<SimpleTarget> setupTarget(ScopeContext scopeContext, List<Interceptor> interceptors,
                                                         List<MessageHandler> requestHandlers,
-                                                        List<MessageHandler> responseHandlers)  throws NoSuchMethodException {
+                                                        List<MessageHandler> responseHandlers) throws NoSuchMethodException {
         Method echo = SimpleTarget.class.getMethod("echo", String.class);
 
         List<Class<?>> targetInterfaces = new ArrayList<Class<?>>();
@@ -144,17 +395,17 @@
         targetWire.setBusinessInterface(SimpleTarget.class);
         targetWire.setServiceName("Target");
         TargetInvocationChainImpl chain = new TargetInvocationChainImpl(echo);
-        if (interceptors != null){
+        if (interceptors != null) {
             for (Interceptor interceptor : interceptors) {
                 chain.addInterceptor(interceptor);
             }
         }
-        if(requestHandlers != null){
+        if (requestHandlers != null) {
             for (MessageHandler handler : requestHandlers) {
                 chain.addRequestHandler(handler);
             }
         }
-        if(responseHandlers != null){
+        if (responseHandlers != null) {
             for (MessageHandler handler : responseHandlers) {
                 chain.addResponseHandler(handler);
             }

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/InvocationErrorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/InvocationErrorTestCase.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/InvocationErrorTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/InvocationErrorTestCase.java Sun May 21 16:48:50 2006
@@ -59,7 +59,7 @@
         Map<Method, InvocationChain> config = new MethodHashMap<InvocationChain>();
         config.put(checkedMethod, getConfiguration(checkedMethod));
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(config);
+        handler.setChains(config);
         try {
             TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                     new Class[]{TestBean.class}, handler);
@@ -74,7 +74,7 @@
         Map<Method, InvocationChain> config = new MethodHashMap<InvocationChain>();
         config.put(runtimeMethod, getConfiguration(runtimeMethod));
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(config);
+        handler.setChains(config);
         try {
             TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                     new Class[]{TestBean.class}, handler);

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerTestCase.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandlerTestCase.java Sun May 21 16:48:50 2006
@@ -40,7 +40,7 @@
         Map<Method, InvocationChain> configs = new MethodHashMap<InvocationChain>();
         configs.put(hello, getInvocationHandler(hello));
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(configs);
+        handler.setChains(configs);
         assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
     }
 
@@ -48,7 +48,7 @@
         Map<Method, InvocationChain> configs = new MethodHashMap<InvocationChain>();
         configs.put(hello, getInvocationHandler(hello));
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(configs);
+        handler.setChains(configs);
         try {
             assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
             fail("Expected " + IllegalArgumentException.class.getName());
@@ -65,7 +65,7 @@
         Map<Method, InvocationChain> configs = new MethodHashMap<InvocationChain>();
         configs.put(hello, source);
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(configs);
+        handler.setChains(configs);
         try {
             assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
             fail("Expected " + IllegalArgumentException.class.getName());
@@ -82,7 +82,7 @@
         Map<Method, InvocationChainImpl> configs = new MethodHashMap<InvocationChainImpl>();
         configs.put(hello, source);
         WireInvocationHandler handler = new JDKInvocationHandler();
-        handler.setConfiguration(configs);
+        handler.setChains(configs);
         assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceContextExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceContextExtension.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceContextExtension.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceContextExtension.java Sun May 21 16:48:50 2006
@@ -75,7 +75,7 @@
         Map<Method, TargetInvocationChain> configuration = targetWire.getInvocationChains();
         assert(configuration != null);
         WireInvocationHandler handler = handlerFactory.getInstance();
-        handler.setConfiguration(configuration);
+        handler.setChains(configuration);
         return handler;
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceContextExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceContextExtension.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceContextExtension.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceContextExtension.java Sun May 21 16:48:50 2006
@@ -62,7 +62,7 @@
 
     public InvocationHandler getHandler() {
         WireInvocationHandler invocationHandler = handlerFactory.getInstance();
-        invocationHandler.setConfiguration(sourceWire.getInvocationChains());
+        invocationHandler.setChains(sourceWire.getInvocationChains());
         return invocationHandler;
     }
 

Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java?rev=408527&r1=408526&r2=408527&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java Sun May 21 16:48:50 2006
@@ -9,5 +9,5 @@
  */
 public interface WireInvocationHandler extends InvocationHandler {
 
-    void setConfiguration(Map<Method, ? extends InvocationChain> configuration);
+    void setChains(Map<Method, ? extends InvocationChain> chains);
 }



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