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/08/31 06:31:15 UTC

svn commit: r438785 [4/4] - in /incubator/tuscany/java/sca: bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/ bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/ bindings/binding.celtix/src/main/java/org/apache/t...

Modified: incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java (original)
+++ incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java Wed Aug 30 21:31:11 2006
@@ -18,18 +18,17 @@
  */
 package org.apache.tuscany.spi.wire;
 
-import java.lang.reflect.Method;
-
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ReferenceDefinition;
 import org.apache.tuscany.spi.model.ReferenceTarget;
-import org.apache.tuscany.spi.model.ServiceDefinition;
-import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
 
 /**
  * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
@@ -39,32 +38,103 @@
 
 public interface WireService {
 
+    /**
+     * Creates a Java proxy for the given wire
+     *
+     * @param wire the wire to proxy
+     * @return the proxy
+     * @throws ProxyCreationException
+     */
     <T> T createProxy(RuntimeWire<T> wire) throws ProxyCreationException;
 
-    <T> T createCallbackProxy(Class<T> interfaze) throws ProxyCreationException;
-
+    /**
+     * Creates a Java proxy for the service contract callback
+     *
+     * @param contract the service contract
+     * @return the proxy
+     * @throws ProxyCreationException
+     */
+    <T> T createCallbackProxy(ServiceContract<?> contract) throws ProxyCreationException;
+
+
+    /**
+     * Creates an {@link WireInvocationHandler} for the given wire
+     *
+     * @param wire the wire to create the invocation handler for
+     * @return the invocation handler
+     */
     <T> WireInvocationHandler createHandler(RuntimeWire<T> wire);
 
+    /**
+     * Creates a wire invocation handler for flowing invocations through a callback
+     *
+     * @return the invocation handler for flowing invocations through a callback
+     */
     WireInvocationHandler createCallbackHandler();
 
-    OutboundWire createOutboundWire();
-
-    InboundWire createInboundWire();
-
-    OutboundInvocationChain createOutboundChain(Method operation);
-
-    InboundInvocationChain createInboundChain(Method operation);
-
+    /**
+     * Creates an outbound invocation chain for a given operation
+     *
+     * @param operation the operation to create the chain for
+     * @return the outbound invocation chain for a given operation
+     */
+    OutboundInvocationChain createOutboundChain(Operation operation);
+
+    /**
+     * Creates an inbound invocation chain for a given operation
+     *
+     * @param operation the operation to create the chain for
+     * @return the inbound invocation chain for a given operation
+     */
+    InboundInvocationChain createInboundChain(Operation operation);
+
+    /**
+     * Creates a wire for flowing inbound invocations to a service
+     *
+     * @param service the model representation of the service
+     * @return the wire for flowing inbound invocations to a service
+     */
     InboundWire createWire(ServiceDefinition service);
 
+    /**
+     * Creates a wire for flowing outbound invocations to a reference
+     *
+     * @param reference the model artifact representing the reference on the source side
+     * @param def       the model artifact representing the target reference
+     * @return the wire for flowing outbound invocations to a reference
+     */
     OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def);
 
+    /**
+     * Creates wires for a component and injects them on the component
+     *
+     * @param component  the component
+     * @param definition the model artifact representing the component
+     */
     void createWires(Component component, ComponentDefinition<?> definition);
 
-    <T> void createWires(Reference<T> reference, ServiceContract contract);
-
+    /**
+     * Creates wires for a reference and injects them on the reference
+     *
+     * @param reference the reference
+     * @param contract  the model artifact representing the service contract for the reference
+     */
+    <T> void createWires(Reference<T> reference, ServiceContract<?> contract);
+
+    /**
+     * Creates wires for a service and injects them on the service
+     *
+     * @param service the service
+     * @param def     the model artifact representing the service
+     */
     void createWires(Service<?> service, BoundServiceDefinition<?> def);
 
+    /**
+     * Creates wires for a composite service and injects them on the service
+     *
+     * @param service the service
+     * @param def     the model artifact representing the service
+     */
     void createWires(Service<?> service, BindlessServiceDefinition def);
 
 }

Modified: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java (original)
+++ incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,11 +18,11 @@
  */
 package org.apache.tuscany.spi.extension;
 
-import java.lang.reflect.Method;
 import java.util.List;
 
 import org.apache.tuscany.spi.ObjectCreationException;
 import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 
 import junit.framework.TestCase;
@@ -78,8 +78,9 @@
             return null;
         }
 
-        public TargetInvoker createTargetInvoker(String serviceName, Method operation) {
+        public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
             return null;
         }
+
     }
 }

Modified: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java (original)
+++ incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.tuscany.spi.extension;
 
-import java.lang.reflect.Method;
 import java.util.List;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
@@ -32,8 +31,8 @@
 import org.apache.tuscany.spi.component.TargetNotFoundException;
 import org.apache.tuscany.spi.event.Event;
 import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.wire.OutboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 
 import junit.framework.TestCase;
@@ -219,11 +218,7 @@
 
         }
 
-        public TargetInvoker createTargetInvoker(String serviceName, Method operation) {
-            return null;
-        }
-
-        public TargetInvoker createAsyncTargetInvoker(String serviceName, Method operation, OutboundWire wire) {
+        public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
             return null;
         }
     }

Modified: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java (original)
+++ incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,12 +18,14 @@
  */
 package org.apache.tuscany.spi.extension;
 
-import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.InvocationChain;
@@ -52,18 +54,18 @@
     }
 
     public void testPrepare() throws Exception {
-        Method method = getClass().getMethod("testPrepare");
         InboundInvocationChain chain = createMock(InboundInvocationChain.class);
+        Operation<Type> operation = new Operation<Type>("test", null, null, null, false, null);
         chain.setTargetInvoker(null);
         expectLastCall();
-        chain.getMethod();
-        expectLastCall().andReturn(method);
+        chain.getOperation();
+        expectLastCall().andReturn(operation);
         chain.prepare();
         expectLastCall();
         InboundWire wire = createMock(InboundWire.class);
         wire.getInvocationChains();
-        Map<Method, InvocationChain> chains = new HashMap<Method, InvocationChain>();
-        chains.put(method, chain);
+        Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
+        chains.put(operation, chain);
         expectLastCall().andReturn(chains);
         OutboundWire outboundWire = createMock(OutboundWire.class);
         outboundWire.getTargetName();
@@ -82,8 +84,10 @@
             super(null, clazz, null, null);
         }
 
-        public TargetInvoker createTargetInvoker(Method operation) {
+        public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
             return null;
         }
+
+
     }
 }

Added: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java?rev=438785&view=auto
==============================================================================
--- incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java (added)
+++ incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java Wed Aug 30 21:31:11 2006
@@ -0,0 +1,166 @@
+/*
+ * 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.spi.idl.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaIDLUtilsTestCase extends TestCase {
+    private Method[] methods;
+    private List<Operation<?>> operations;
+
+    public void testNoParamsFindMethod() {
+        Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertEquals("foo", method.getName());
+        assertEquals(0, method.getParameterTypes().length);
+    }
+
+    public void testNoParamsFindOperation() throws Exception {
+        Method method = Foo.class.getMethod("foo");
+        Operation ret = findOperation(method, operations);
+        assertEquals("foo", ret.getName());
+        assertEquals(0, method.getParameterTypes().length);
+    }
+
+    public void testParamsFindMethod() {
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(String.class, Object.class);
+        types.add(type);
+        Operation<Type> operation = new Operation<Type>("foo", null, types, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertEquals("foo", method.getName());
+        assertEquals(String.class, method.getParameterTypes()[0]);
+    }
+
+    public void testParamsFindOperation() throws Exception {
+        Method method = Foo.class.getMethod("foo",String.class);
+        Operation ret = findOperation(method, operations);
+        assertEquals("foo", ret.getName());
+        assertEquals(String.class, method.getParameterTypes()[0]);
+    }
+
+
+    public void testTooManyParamsFindMethod() {
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(String.class, Object.class);
+        DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+        types.add(type);
+        types.add(type2);
+        Operation<Type> operation = new Operation<Type>("foo", null, types, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertNull(method);
+    }
+
+    public void testDifferentParamsFindMethod() {
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+        types.add(type);
+        Operation<Type> operation = new Operation<Type>("foo", null, types, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertNull(method);
+    }
+
+    public void testPrimitiveParamNoFindMethod() {
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+        types.add(type);
+        Operation<Type> operation = new Operation<Type>("foo", null, types, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertNull(method);
+    }
+
+    public void testPrimitiveParamFindMethod() {
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(Integer.TYPE, Object.class);
+        types.add(type);
+        Operation<Type> operation = new Operation<Type>("foo", null, types, null, false, null);
+        Method method = findMethod(operation, methods);
+        assertEquals("foo", method.getName());
+        assertEquals(Integer.TYPE, method.getParameterTypes()[0]);
+    }
+
+    public void testPrimitiveParamFindOperation() throws NoSuchMethodException {
+        Method method = Foo.class.getMethod("foo", Integer.TYPE);
+        Operation<?> operation = findOperation(method, operations);
+        assertEquals(Integer.TYPE, operation.getParameterTypes().get(0).getPhysical());
+    }
+
+
+    public void testNotFoundMethod() {
+        Operation<Type> operation = new Operation<Type>("not there", null, null, null, false, null);
+        assertNull(findMethod(operation, methods));
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        methods = Foo.class.getMethods();
+
+        Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+        operations = new ArrayList<Operation<?>>();
+        operations.add(operation);
+
+        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+        DataType<Type> type = new DataType<Type>(String.class, Object.class);
+        types.add(type);
+        operation = new Operation<Type>("foo", null, types, null, false, null);
+        operations.add(operation);
+
+        types = new ArrayList<DataType<Type>>();
+        type = new DataType<Type>(String.class, Object.class);
+        DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+        types.add(type);
+        types.add(type2);
+        operation = new Operation<Type>("foo", null, types, null, false, null);
+        operations.add(operation);
+
+        types = new ArrayList<DataType<Type>>();
+        type = new DataType<Type>(Integer.class, Object.class);
+        types.add(type);
+        operation = new Operation<Type>("foo", null, types, null, false, null);
+        operations.add(operation);
+
+        types = new ArrayList<DataType<Type>>();
+        type = new DataType<Type>(Integer.TYPE, Object.class);
+        types.add(type);
+        operation = new Operation<Type>("foo", null, types, null, false, null);
+        operations.add(operation);
+
+    }
+
+    private interface Foo {
+        void foo();
+
+        void foo(String foo);
+
+        void foo(int b);
+    }
+}

Propchange: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java?rev=438785&view=auto
==============================================================================
--- incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java (added)
+++ incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java Wed Aug 30 21:31:11 2006
@@ -0,0 +1,56 @@
+/*
+ * 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.spi.model;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Type;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceContractTestCase extends TestCase {
+
+    public void testAddOperation() throws Exception {
+        ServiceContract<Type> contract = new TestContract();
+        Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+        Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+        ops.put("foo", operation);
+        contract.setOperations(ops);
+        assertEquals(contract, operation.getServiceContract());
+        assertFalse(operation.isCallback());
+    }
+
+    public void testAddCallbackOperation() throws Exception {
+        ServiceContract<Type> contract = new TestContract();
+        Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+        Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+        ops.put("foo", operation);
+        contract.setCallbacksOperations(ops);
+        assertEquals(contract, operation.getServiceContract());
+        assertTrue(operation.isCallback());
+    }
+
+
+    private class TestContract extends ServiceContract<Type> {
+
+    }
+}

Propchange: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java (original)
+++ incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java Wed Aug 30 21:31:11 2006
@@ -18,29 +18,32 @@
  */
 package org.apache.tuscany.test;
 
-import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
 import org.apache.tuscany.core.builder.ConnectorImpl;
-import org.apache.tuscany.core.util.MethodHashMap;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
 import org.apache.tuscany.core.wire.InboundWireImpl;
 import org.apache.tuscany.core.wire.InvokerInterceptor;
 import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
 import org.apache.tuscany.core.wire.OutboundWireImpl;
 import org.apache.tuscany.core.wire.jdk.JDKWireService;
-import org.apache.tuscany.spi.builder.Connector;
-import org.apache.tuscany.spi.wire.InboundInvocationChain;
-import org.apache.tuscany.spi.wire.InboundWire;
-import org.apache.tuscany.spi.wire.OutboundInvocationChain;
-import org.apache.tuscany.spi.wire.OutboundWire;
-import org.apache.tuscany.spi.wire.WireService;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 
 /**
- * A factory for creating runtime artifacts to facilitate testing without directly instantiating core
- * implementation classes
+ * A factory for creating runtime artifacts to facilitate testing without directly instantiating core implementation
+ * classes
  *
  * @version $$Rev$$ $$Date$$
  */
@@ -59,15 +62,17 @@
 
     /**
      * Creates an inbound wire. After a wire is returned, client code must call {@link
-     * #terminateWire(org.apache.tuscany.spi.wire.InboundWire<T>)}. These two methods have been separated
-     * to allow wires to be decorated with interceptors or handlers prior to their completion
+     * #terminateWire(org.apache.tuscany.spi.wire.InboundWire<T>)}. These two methods have been separated to allow wires
+     * to be decorated with interceptors or handlers prior to their completion
      *
      * @param serviceName the service name associated with the wire
      * @param interfaze   the interface associated with the wire
      */
-    public static <T> InboundWire<T> createInboundWire(String serviceName, Class<T> interfaze) {
+    public static <T> InboundWire<T> createInboundWire(String serviceName, Class<T> interfaze)
+        throws InvalidServiceContractException {
         InboundWire<T> wire = new InboundWireImpl<T>();
-        JavaServiceContract contract = new JavaServiceContract(interfaze);
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        ServiceContract<?> contract = registry.introspect(interfaze);
         wire.setServiceContract(contract);
         wire.setServiceName(serviceName);
         wire.addInvocationChains(createInboundChains(interfaze));
@@ -76,17 +81,19 @@
 
     /**
      * Creates an outbound wire. After a wire is returned, client code must call {@link
-     * #terminateWire(org.apache.tuscany.spi.wire.OutboundWire<T>)}. These two methods have been separated
-     * to allow wires to be decorated with interceptors or handlers prior to their completion
+     * #terminateWire(org.apache.tuscany.spi.wire.OutboundWire<T>)}. These two methods have been separated to allow
+     * wires to be decorated with interceptors or handlers prior to their completion
      *
      * @param refName   the reference name the wire is associated with on the client
      * @param interfaze the interface associated with the wire
      */
-    public static <T> OutboundWire<T> createOutboundWire(String refName, Class<T> interfaze) {
+    public static <T> OutboundWire<T> createOutboundWire(String refName, Class<T> interfaze)
+        throws InvalidServiceContractException {
         OutboundWire<T> wire = new OutboundWireImpl<T>();
         wire.setReferenceName(refName);
         wire.addInvocationChains(createOutboundChains(interfaze));
-        JavaServiceContract contract = new JavaServiceContract(interfaze);
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        ServiceContract<?> contract = registry.introspect(interfaze);
         wire.setServiceContract(contract);
         return wire;
     }
@@ -109,24 +116,28 @@
         }
     }
 
-    private static Map<Method, OutboundInvocationChain> createOutboundChains(Class<?> interfaze) {
-        Map<Method, OutboundInvocationChain> invocations = new HashMap<Method, OutboundInvocationChain>();
-        Method[] methods = interfaze.getMethods();
-        for (Method method : methods) {
-            OutboundInvocationChain chain = new OutboundInvocationChainImpl(method);
-            invocations.put(method, chain);
+    private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze)
+        throws InvalidServiceContractException {
+        Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        ServiceContract<?> contract = registry.introspect(interfaze);
+        for (Operation operation : contract.getOperations().values()) {
+            OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+            invocations.put(operation, chain);
         }
         return invocations;
     }
 
-    private static Map<Method, InboundInvocationChain> createInboundChains(Class<?> interfaze) {
-        Map<Method, InboundInvocationChain> invocations = new MethodHashMap<InboundInvocationChain>();
-        Method[] methods = interfaze.getMethods();
-        for (Method method : methods) {
-            InboundInvocationChain chain = new InboundInvocationChainImpl(method);
+    private static Map<Operation, InboundInvocationChain> createInboundChains(Class<?> interfaze)
+        throws InvalidServiceContractException {
+        Map<Operation, InboundInvocationChain> invocations = new HashMap<Operation, InboundInvocationChain>();
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        ServiceContract<?> contract = registry.introspect(interfaze);
+        for (Operation operation : contract.getOperations().values()) {
+            InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
             // add tail interceptor
             //chain.addInterceptor(new InvokerInterceptor());
-            invocations.put(method, chain);
+            invocations.put(operation, chain);
         }
         return invocations;
     }

Modified: incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java (original)
+++ incubator/tuscany/java/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java Wed Aug 30 21:31:11 2006
@@ -1,9 +1,9 @@
 package org.apache.tuscany.test.binding;
 
-import java.lang.reflect.Method;
-
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.extension.ReferenceExtension;
+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;
 
@@ -16,7 +16,7 @@
         super(name, interfaze, parent, wireService);
     }
 
-    public TargetInvoker createTargetInvoker(Method operation) {
+    public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
         return new TestInvoker();
     }
 }



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