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/10/04 10:38:23 UTC

svn commit: r452795 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/implementation/composite/ core/src/test/java/org/apache/tuscany/core/implementation/composite/ spi/src/main/java/org/apache/tuscany/spi/wire/

Author: jmarino
Date: Wed Oct  4 01:38:22 2006
New Revision: 452795

URL: http://svn.apache.org/viewvc?view=rev&rev=452795
Log:
[PATCH] from Ignacio for Tuscany-767

Added:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java   (with props)
Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,74 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Base class for dispatching to a Composite Reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractCompositeReferenceTargetInvoker implements TargetInvoker {
+
+    protected Operation operation;
+    protected boolean cacheable;
+
+    public AbstractCompositeReferenceTargetInvoker(Operation operation) {
+        assert operation != null : "Operation method cannot be null";
+        this.operation = operation;
+    }
+
+    public boolean isCacheable() {
+        return cacheable;
+    }
+
+    public void setCacheable(boolean cacheable) {
+        this.cacheable = cacheable;
+    }
+
+    public boolean isOptimizable() {
+        return isCacheable(); // we only need to check if the scopes are correct
+    }
+
+    public Object invokeTarget(final Object payload) throws InvocationTargetException {
+        Object[] args;
+        if (payload != null && !payload.getClass().isArray()) {
+            args = new Object[]{payload};
+        } else {
+            args = (Object[]) payload;
+        }
+        try {
+            AbstractOperationOutboundInvocationHandler invocationHandler = getInvocationHandler();
+            return invocationHandler.invoke(operation, args);
+        } catch (Throwable t) {
+            throw new InvocationTargetException(t);
+        }
+    }
+
+    @Override
+    public AbstractCompositeReferenceTargetInvoker clone() throws CloneNotSupportedException {
+        return (AbstractCompositeReferenceTargetInvoker) super.clone();
+    }
+
+    protected abstract AbstractOperationOutboundInvocationHandler getInvocationHandler();
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,10 @@
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.core.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.model.Operation;
+
+public abstract class AbstractOperationOutboundInvocationHandler
+    extends AbstractOutboundInvocationHandler {
+
+    public abstract Object invoke(Operation operation, Object[] args) throws Throwable;
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java?view=diff&rev=452795&r1=452794&r2=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java Wed Oct  4 01:38:22 2006
@@ -15,19 +15,17 @@
  */
 package org.apache.tuscany.core.implementation.composite;
 
-import java.lang.reflect.Method;
-
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.ReferenceExtension;
-import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 import org.apache.tuscany.spi.wire.WireService;
 
-import org.apache.tuscany.core.injection.WireObjectFactory;
-
+/**
+ * A bindless reference to a target service in the parent composite
+ */
 public class CompositeReference extends ReferenceExtension {
 
     private WorkContext workContext;
@@ -42,13 +40,10 @@
     }
 
     public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
-        WireObjectFactory wireFactory = new WireObjectFactory(outboundWire, wireService);
-        Method method = JavaIDLUtils.findMethod(operation, contract.getInterfaceClass().getMethods());
-        return new CompositeReferenceTargetInvoker(method, inboundWire, wireFactory, workContext);
+        return new CompositeReferenceTargetInvoker(operation, inboundWire, outboundWire, workContext);
     }
 
     public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
-        Method method = JavaIDLUtils.findMethod(operation, contract.getCallbackClass().getMethods());
-        return new CompositeReferenceCallbackTargetInvoker(method, contract, inboundWire, wireService, workContext);
+        return new CompositeReferenceCallbackTargetInvoker(operation, inboundWire, workContext);
     }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java?view=diff&rev=452795&r1=452794&r2=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java Wed Oct  4 01:38:22 2006
@@ -16,45 +16,25 @@
 package org.apache.tuscany.core.implementation.composite;
 
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
-import org.apache.tuscany.spi.component.TargetException;
 import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.InvocationRuntimeException;
 import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.WireService;
 
-import org.apache.tuscany.core.wire.PojoTargetInvoker;
+/**
+ * 
+ */
+public class CompositeReferenceCallbackTargetInvoker extends AbstractCompositeReferenceTargetInvoker {
 
-public class CompositeReferenceCallbackTargetInvoker extends PojoTargetInvoker {
-
-    private ServiceContract<?> contract;
     private InboundWire inboundWire;
-    private WireService wireService;
     private WorkContext workContext;
 
-
-    public CompositeReferenceCallbackTargetInvoker(Method operation,
-                                                   ServiceContract contract,
-                                                   InboundWire inboundWire,
-                                                   WireService wireService,
-                                                   WorkContext workContext) {
+    public CompositeReferenceCallbackTargetInvoker(Operation operation, InboundWire inboundWire, WorkContext context) {
         super(operation);
-        this.contract = contract;
         this.inboundWire = inboundWire;
-        this.wireService = wireService;
-        this.workContext = workContext;
-    }
-
-    public CompositeReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
-        CompositeReferenceCallbackTargetInvoker invoker = (CompositeReferenceCallbackTargetInvoker) super.clone();
-        invoker.contract = this.contract;
-        invoker.inboundWire = this.inboundWire;
-        invoker.wireService = this.wireService;
-        invoker.workContext = this.workContext;
-        return invoker;
+        this.workContext = context;
     }
 
     public Message invoke(Message msg) throws InvocationRuntimeException {
@@ -71,7 +51,11 @@
         return msg;
     }
 
-    protected Object getInstance() throws TargetException {
-        return wireService.createCallbackProxy(contract, inboundWire);
+    public CompositeReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+        return (CompositeReferenceCallbackTargetInvoker) super.clone();
+    }
+
+    protected AbstractOperationOutboundInvocationHandler getInvocationHandler() {
+        return new OperationCallbackInvocationHandler(workContext, inboundWire);
     }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java?view=diff&rev=452795&r1=452794&r2=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java Wed Oct  4 01:38:22 2006
@@ -16,44 +16,37 @@
 package org.apache.tuscany.core.implementation.composite;
 
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
-import org.apache.tuscany.spi.component.TargetException;
 import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.InvocationRuntimeException;
 import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.OutboundWire;
 
-import org.apache.tuscany.core.injection.WireObjectFactory;
-import org.apache.tuscany.core.wire.PojoTargetInvoker;
+/**
+ *
+ */
+public class CompositeReferenceTargetInvoker extends AbstractCompositeReferenceTargetInvoker {
 
-public class CompositeReferenceTargetInvoker extends PojoTargetInvoker {
-
-    private InboundWire wire;
-    private WireObjectFactory wireFactory;
+    private InboundWire inboundWire;
+    private OutboundWire outboundWire;
     private WorkContext workContext;
 
 
-    public CompositeReferenceTargetInvoker(Method operation,
-                                           InboundWire wire,
-                                           WireObjectFactory wireFactory, WorkContext workContext) {
+    public CompositeReferenceTargetInvoker(Operation operation,
+                                           InboundWire inboundWire,
+                                           OutboundWire outboundWire,
+                                           WorkContext workContext) {
         super(operation);
-        this.wire = wire;
-        this.wireFactory = wireFactory;
+        this.inboundWire = inboundWire;
+        this.outboundWire = outboundWire;
         this.workContext = workContext;
     }
 
-    public CompositeReferenceTargetInvoker clone() throws CloneNotSupportedException {
-        CompositeReferenceTargetInvoker invoker = (CompositeReferenceTargetInvoker) super.clone();
-        invoker.wire = this.wire;
-        invoker.wireFactory = this.wireFactory;
-        invoker.workContext = this.workContext;
-        return invoker;
-    }
-
     public Message invoke(Message msg) throws InvocationRuntimeException {
         try {
-            wire.addMapping(msg.getMessageId(), msg.getFromAddress());
+            inboundWire.addMapping(msg.getMessageId(), msg.getFromAddress());
             workContext.setCurrentMessageId(msg.getMessageId());
             workContext.setCurrentCorrelationId(msg.getCorrelationId());
             Object resp = invokeTarget(msg.getBody());
@@ -66,7 +59,11 @@
         return msg;
     }
 
-    protected Object getInstance() throws TargetException {
-        return wireFactory.getInstance();
+    public CompositeReferenceTargetInvoker clone() throws CloneNotSupportedException {
+        return (CompositeReferenceTargetInvoker) super.clone();
+    }
+    
+    protected AbstractOperationOutboundInvocationHandler getInvocationHandler() {
+        return new OperationOutboundInvocationHandler(outboundWire, workContext);
     }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java?view=diff&rev=452795&r1=452794&r2=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java Wed Oct  4 01:38:22 2006
@@ -13,21 +13,16 @@
  */
 package org.apache.tuscany.core.implementation.composite;
 
-import java.lang.reflect.Method;
-
 import org.apache.tuscany.spi.CoreRuntimeException;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.TargetException;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.ServiceExtension;
-import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 import org.apache.tuscany.spi.wire.WireService;
 
-import org.apache.tuscany.core.injection.WireObjectFactory;
-
 public class CompositeService extends ServiceExtension {
 
     private WorkContext workContext;
@@ -48,16 +43,13 @@
      * FIXME !!! Notice that this method is not defined in the SPI !!!
      */
     public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
-        WireObjectFactory wireFactory = new WireObjectFactory(outboundWire, wireService);
-        Method method = JavaIDLUtils.findMethod(operation, contract.getInterfaceClass().getMethods());
-        return new CompositeReferenceTargetInvoker(method, inboundWire, wireFactory, workContext);
+        return new CompositeReferenceTargetInvoker(operation, inboundWire, outboundWire, workContext);
     }
 
     /**
      */
     public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
-        Method method = JavaIDLUtils.findMethod(operation, contract.getCallbackClass().getMethods());
-        return new CompositeReferenceCallbackTargetInvoker(method, contract, inboundWire, wireService, workContext);
+         return new CompositeReferenceCallbackTargetInvoker(operation, inboundWire, workContext);
     }
 
     public Object getServiceInstance() throws TargetException {

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,77 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * 
+ */
+public class OperationCallbackInvocationHandler extends AbstractOperationOutboundInvocationHandler {
+
+    private WorkContext context;
+    private InboundWire inboundWire;
+    private Object messageId;
+    private Object correlationId;
+
+    public OperationCallbackInvocationHandler(WorkContext context, InboundWire inboundWire) {
+        this.context = context;
+        this.inboundWire = inboundWire;
+    }
+
+    public Object invoke(Object proxy, Operation operation, Object[] args) throws Throwable {
+        messageId = context.getCurrentMessageId();
+        context.setCurrentMessageId(null);
+        correlationId = context.getCurrentCorrelationId();
+        context.setCurrentCorrelationId(null);
+        Object targetAddress = inboundWire.retrieveMapping(correlationId);
+        if (targetAddress == null) {
+            throw new AssertionError("No from address associated with message id [" + correlationId + "]");
+        }
+        //TODO optimize as this is slow in local invocations
+        Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
+            inboundWire.getSourceCallbackInvocationChains(targetAddress);
+        OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
+        TargetInvoker invoker = chain.getTargetInvoker();
+        return invoke(chain, invoker, args);
+    }
+
+
+    public Object invoke(Operation operation, Object[] args) throws Throwable {
+        return invoke(null, operation, args);
+    }
+
+    protected Object getFromAddress() {
+        return (inboundWire.getContainer() == null) ? null : inboundWire.getContainer().getName();
+    }
+    
+    protected Object getMessageId() {
+        return messageId;
+    }
+    
+    protected Object getCorrelationId() {
+        return correlationId;
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,127 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * 
+ */
+public class OperationOutboundInvocationHandler extends AbstractOperationOutboundInvocationHandler {
+
+    /*
+     * an association of an operation to chain holder. The holder contains an invocation 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 chains will be used.
+     */
+    private Map<Operation, ChainHolder> chains;
+    private WorkContext context;
+    private Object fromAddress;
+    private Object messageId;
+    private Object correlationId;
+
+    public OperationOutboundInvocationHandler(OutboundWire wire, WorkContext context) {
+        Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
+        this.chains = new HashMap<Operation, ChainHolder>(invocationChains.size());
+        this.fromAddress = (wire.getContainer() == null) ? null : wire.getContainer().getName();
+        // TODO optimize this
+        for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
+            Operation operation = entry.getKey();
+            this.chains.put(operation, new ChainHolder(entry.getValue()));
+        }
+
+        this.context = context;
+    }
+
+    public Object invoke(Object proxy, Operation operation, Object[] args) throws Throwable {
+        ChainHolder holder = chains.get(operation);
+        if (holder == null) {
+            TargetException e = new TargetException("Operation not configured");
+            e.setIdentifier(operation.getName());
+            throw e;
+        }
+        OutboundInvocationChain chain = holder.chain;
+        TargetInvoker invoker;
+
+        if (holder.cachedInvoker == null) {
+            assert chain != null;
+            if (chain.getTargetInvoker() == null) {
+                TargetException e = new TargetException("No target invoker configured for operation");
+                e.setIdentifier(chain.getOperation().getName());
+                throw e;
+            }
+            if (chain.getTargetInvoker().isCacheable()) {
+                // clone and store the invoker locally
+                holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
+                invoker = holder.cachedInvoker;
+            } else {
+                invoker = chain.getTargetInvoker();
+            }
+        } else {
+            assert chain != null;
+            invoker = chain.getTargetInvoker();
+        }
+        messageId = context.getCurrentMessageId();
+        context.setCurrentMessageId(null);
+        correlationId = context.getCurrentCorrelationId();
+        context.setCurrentCorrelationId(null);
+        return invoke(chain, invoker, args);
+    }
+
+    public Object invoke(Operation operation, Object[] args) throws Throwable {
+        return invoke(null, operation, args);
+    }
+
+    protected Object getFromAddress() {
+        return fromAddress;
+    }
+
+    protected Object getMessageId() {
+        return messageId;
+    }
+
+    protected Object getCorrelationId() {
+        return correlationId;
+    }
+
+    /**
+     * 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 ChainHolder {
+
+        OutboundInvocationChain chain;
+        TargetInvoker cachedInvoker;
+
+        public ChainHolder(OutboundInvocationChain config) {
+            this.chain = config;
+        }
+
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,102 @@
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase extends TestCase {
+    private InboundWire wire;
+    private WorkContext context;
+    private Message message;
+    private OutboundInvocationChain chain;
+    private CompositeReferenceCallbackTargetInvoker invoker;
+
+    /**
+     * Verfies an InvocationTargetException thrown when invoking the target is propagated to the client correctly and
+     * the originating error is unwrapped
+     */
+    public void testThrowableTargetInvocation() throws Exception {
+        Message response = invoker.invoke(message);
+        assertTrue(response.isFault());
+        Object body = response.getBody();
+        assertTrue(SomeException.class.equals(body.getClass()));
+        EasyMock.verify(wire);
+        EasyMock.verify(context);
+        EasyMock.verify(chain);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object id = new Object();
+        Object corrId = new Object();
+        Object targetAddress = new Object();
+        message = new MessageImpl();
+        message.setMessageId(id);
+        message.setCorrelationId(corrId);
+        message.setBody("foo");
+        Message response = new MessageImpl();
+        response.setBody("response");
+        Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+        Interceptor head = new ErrorInterceptor();
+        chain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+        EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+        EasyMock.replay(chain);
+        Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+        chains.put(operation, chain);
+        wire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+        EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+        EasyMock.expect(wire.getContainer()).andReturn(null);
+        EasyMock.replay(wire);
+        context = EasyMock.createMock(WorkContext.class);
+        context.setCurrentMessageId(EasyMock.eq(id));
+        context.setCurrentMessageId(EasyMock.isNull());
+        context.setCurrentCorrelationId(corrId);
+        context.setCurrentCorrelationId(EasyMock.isNull());
+        EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+        EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+        EasyMock.replay(context);
+        invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+    }
+
+    private class SomeException extends Exception {
+
+    }
+
+    private class ErrorInterceptor implements Interceptor {
+
+        public Message invoke(Message msg) {
+            msg.setBodyWithFault(new SomeException());
+            return msg;
+        }
+
+        public void setNext(Interceptor next) {
+
+        }
+
+        public Interceptor getNext() {
+            return null;
+        }
+
+        public boolean isOptimizable() {
+            return false;
+        }
+    }
+
+
+}

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

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

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,97 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerTestCase extends TestCase {
+    private InboundWire wire;
+    private WorkContext context;
+    private Message message;
+    private OutboundInvocationChain chain;
+    private Interceptor head;
+    private CompositeReferenceCallbackTargetInvoker invoker;
+
+    /**
+     * Verfies the normal execution path through a callback
+     */
+    public void testNormalPathMessageInvocation() throws Exception {
+        Message response = invoker.invoke(message);
+        assertEquals("response", response.getBody());
+        EasyMock.verify(wire);
+        EasyMock.verify(context);
+        EasyMock.verify(chain);
+        EasyMock.verify(head);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object id = new Object();
+        Object corrId = new Object();
+        Object targetAddress = new Object();
+        message = new MessageImpl();
+        message.setMessageId(id);
+        message.setCorrelationId(corrId);
+        message.setBody("foo");
+        Message response = new MessageImpl();
+        response.setBody("response");
+        Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+        head = EasyMock.createMock(Interceptor.class);
+        EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andReturn(response);
+        EasyMock.replay(head);
+        chain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+        EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+        EasyMock.replay(chain);
+        Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+        chains.put(operation, chain);
+        wire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+        EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+        EasyMock.expect(wire.getContainer()).andReturn(null);
+        EasyMock.replay(wire);
+        context = EasyMock.createMock(WorkContext.class);
+        context.setCurrentMessageId(EasyMock.eq(id));
+        context.setCurrentMessageId(EasyMock.isNull());
+        context.setCurrentCorrelationId(corrId);
+        context.setCurrentCorrelationId(EasyMock.isNull());
+        EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+        EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+        EasyMock.replay(context);
+        invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+    }
+
+
+}

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

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

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,113 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerThrowableTestCase extends TestCase {
+    private InboundWire wire;
+    private WorkContext context;
+    private Message message;
+    private OutboundInvocationChain chain;
+    private Interceptor head;
+    private CompositeReferenceCallbackTargetInvoker invoker;
+
+    /**
+     * Verfies an exception thrown in the target is propagated to the client correctly
+     */
+    public void testThrowableTargetInvocation() throws Exception {
+        Message response = invoker.invoke(message);
+        assertTrue(response.isFault());
+        Object body = response.getBody();
+        if (!(body instanceof UndeclaredThrowableException)) {
+            fail(); // EasyMock wraps the Throwable in an UndeclaredThrowableException
+        }
+        UndeclaredThrowableException e = (UndeclaredThrowableException) body;
+        assertTrue(InsidiousException.class.equals(e.getUndeclaredThrowable().getClass()));
+        EasyMock.verify(wire);
+        EasyMock.verify(context);
+        EasyMock.verify(chain);
+        EasyMock.verify(head);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Object id = new Object();
+        Object corrId = new Object();
+        Object targetAddress = new Object();
+        message = new MessageImpl();
+        message.setMessageId(id);
+        message.setCorrelationId(corrId);
+        message.setBody("foo");
+        Message response = new MessageImpl();
+        response.setBody("response");
+        Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+        head = EasyMock.createMock(Interceptor.class);
+        EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andStubAnswer(new IAnswer() {
+            public Object answer() throws Throwable {
+                throw new InsidiousException();   // andThrow() does not seem to work here
+            }
+        });
+        EasyMock.replay(head);
+        chain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+        EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+        EasyMock.replay(chain);
+        Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+        chains.put(operation, chain);
+        wire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+        EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+        EasyMock.expect(wire.getContainer()).andReturn(null);
+        EasyMock.replay(wire);
+        context = EasyMock.createMock(WorkContext.class);
+        context.setCurrentMessageId(EasyMock.eq(id));
+        context.setCurrentMessageId(EasyMock.isNull());
+        context.setCurrentCorrelationId(corrId);
+        context.setCurrentCorrelationId(EasyMock.isNull());
+        EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+        EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+        EasyMock.replay(context);
+        invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+    }
+
+    private class InsidiousException extends Throwable {
+
+    }
+
+
+}

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

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

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java?view=auto&rev=452795
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java Wed Oct  4 01:38:22 2006
@@ -0,0 +1,63 @@
+/*
+ * 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.core.implementation.composite;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ */
+public class CompositeReferenceTestCase extends TestCase {
+
+    public void testCreateTargetInvoker() throws Exception {
+        
+        MyServiceContract serviceContract = new MyServiceContract();
+        CompositeReference compositeReference = new CompositeReference("testCompositeReferemce",
+                                                                       null,
+                                                                       null,
+                                                                       serviceContract,
+                                                                       null);
+        Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+        TargetInvoker targetInvoker = compositeReference.createTargetInvoker(serviceContract, operation);
+        assertNotNull(targetInvoker);
+    }
+    
+    public void testCreateCallbackTargetInvoker() throws Exception {
+        
+        MyServiceContract serviceContract = new MyServiceContract();
+        CompositeReference compositeReference = new CompositeReference("testCompositeReferemce",
+                                                                       null,
+                                                                       null,
+                                                                       serviceContract,
+                                                                       null);
+        Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+        TargetInvoker targetInvoker = compositeReference.createCallbackTargetInvoker(serviceContract, operation);
+        assertNotNull(targetInvoker);
+    }
+    
+    class MyServiceContract extends ServiceContract {
+        
+    }
+}

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

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

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=452795&r1=452794&r2=452795
==============================================================================
--- 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 Wed Oct  4 01:38:22 2006
@@ -141,13 +141,16 @@
      * 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: the success of checkCompatibility(A, B) does NOT imply that checkCompatibility(B, A)
+     * <p>Please note this test is not symetric: the success of checkCompatibility(A, B) does NOT imply that
+     * checkCompatibility(B, A)
      *
-     * @param source The source service contract
-     * @param target The target service contract
+     * @param source         The source service contract
+     * @param target         The target service contract
      * @param ignoreCallback Indicate the callback should be checked
-     * @throws IncompatibleServiceContractException If the source service contract is not compatible with the target one
+     * @throws IncompatibleServiceContractException
+     *          If the source service contract is not compatible with the target one
      */
-    void checkCompatibility(ServiceContract<?> source, ServiceContract<?> target, boolean ignoreCallback) throws IncompatibleServiceContractException;
+    void checkCompatibility(ServiceContract<?> source, ServiceContract<?> target, boolean ignoreCallback)
+        throws IncompatibleServiceContractException;
 
 }



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