You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/05/04 01:24:12 UTC

svn commit: r535028 - in /incubator/tuscany/java/sca: modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/ modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/ modules/core-spi/src/main/java/org...

Author: rfeng
Date: Thu May  3 16:24:10 2007
New Revision: 535028

URL: http://svn.apache.org/viewvc?view=rev&rev=535028
Log:
Add WireProcessorExtensionPoint/RuntimeWireProcessorExtension and bring up the echo-databinding sample with the new contract

Added:
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java   (with props)
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java   (with props)
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java   (with props)
Removed:
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingBuilder.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoConstants.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoReference.java
Modified:
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/DataBindingModuleActivator.java
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWire.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/PojoAtomicComponent.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/DefaultEchoBindingFactory.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBinding.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingFactory.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingImpl.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProcessor.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoModuleActivator.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoServer.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java
    incubator/tuscany/java/sca/samples/databinding-echo/src/test/java/echo/EchoDataBindingTestCase.java

Modified: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/DataBindingModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/DataBindingModuleActivator.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/DataBindingModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/module/DataBindingModuleActivator.java Thu May  3 16:24:10 2007
@@ -24,11 +24,14 @@
 
 import org.apache.tuscany.core.ExtensionPointRegistry;
 import org.apache.tuscany.core.ModuleActivator;
+import org.apache.tuscany.core.WireProcessorExtensionPoint;
 import org.apache.tuscany.core.databinding.processor.DataBindingJavaInterfaceProcessor;
 import org.apache.tuscany.core.databinding.transformers.Exception2ExceptionTransformer;
 import org.apache.tuscany.core.databinding.transformers.Input2InputTransformer;
 import org.apache.tuscany.core.databinding.transformers.Output2OutputTransformer;
+import org.apache.tuscany.core.databinding.wire.DataBindingRuntimeWireProcessor;
 import org.apache.tuscany.core.databinding.wire.DataBindingWirePostProcessor;
+import org.apache.tuscany.core.databinding.wire.DataTransformationInteceptor;
 import org.apache.tuscany.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.databinding.DefaultDataBindingExtensionPoint;
 import org.apache.tuscany.databinding.DefaultTransformerExtensionPoint;
@@ -69,7 +72,7 @@
  * @version $Rev$ $Date$
  */
 public class DataBindingModuleActivator implements ModuleActivator {
-    
+
     private DataBindingExtensionPoint dataBindings;
     private TransformerExtensionPoint transformers;
 
@@ -97,13 +100,23 @@
         transformers.addTransformer(output2OutputTransformer);
         transformers.addTransformer(exception2ExceptionTransformer);
 
-        JavaInterfaceIntrospectorExtensionPoint introspectors = registry.getExtensionPoint(JavaInterfaceIntrospectorExtensionPoint.class);
+        JavaInterfaceIntrospectorExtensionPoint introspectors = registry
+            .getExtensionPoint(JavaInterfaceIntrospectorExtensionPoint.class);
         introspectors.addInterfaceVisitor(new DataBindingJavaInterfaceProcessor(dataBindings));
 
+        // To be removed
         WirePostProcessorRegistry postProcessors = registry.getExtensionPoint(WirePostProcessorRegistry.class);
-        ComponentManager componentManager = registry.getExtensionPoint(ComponentManager.class);
-        postProcessors.register(new DataBindingWirePostProcessor(componentManager, mediator));
-        
+        if (postProcessors != null) {
+            ComponentManager componentManager = registry.getExtensionPoint(ComponentManager.class);
+            postProcessors.register(new DataBindingWirePostProcessor(componentManager, mediator));
+        }
+
+        WireProcessorExtensionPoint wireProcessorExtensionPoint = registry
+            .getExtensionPoint(WireProcessorExtensionPoint.class);
+        if (wireProcessorExtensionPoint != null) {
+            wireProcessorExtensionPoint.register(new DataBindingRuntimeWireProcessor(mediator));
+        }
+
         DOMDataBinding domDataBinding = new DOMDataBinding();
         domDataBinding.setDataBindingRegistry(dataBindings);
         dataBindings.addDataBinding(domDataBinding);
@@ -117,10 +130,10 @@
         javaBeansDataBinding.setDataBindingRegistry(dataBindings);
         dataBindings.addDataBinding(javaBeansDataBinding);
 
-        Group2GroupTransformer group2GroupTransformer= new Group2GroupTransformer();
+        Group2GroupTransformer group2GroupTransformer = new Group2GroupTransformer();
         group2GroupTransformer.setMediator(mediator);
         transformers.addTransformer(group2GroupTransformer);
-        
+
         transformers.addTransformer(new InputSource2Node());
         transformers.addTransformer(new InputSource2SAX());
         transformers.addTransformer(new InputStream2Node());
@@ -137,7 +150,7 @@
 
         transformers.addTransformer(new Reader2SAX());
         transformers.addTransformer(new SAX2DOMPipe());
-        
+
         transformers.addTransformer(new Source2ResultTransformer());
         transformers.addTransformer(new StreamDataPipe());
         transformers.addTransformer(new String2Node());
@@ -149,7 +162,7 @@
         transformers.addTransformer(new XMLStreamReader2SAX());
         transformers.addTransformer(new XMLStreamReader2String());
     }
-    
+
     public void stop(ExtensionPointRegistry registry) {
     }
 }

Added: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java Thu May  3 16:24:10 2007
@@ -0,0 +1,150 @@
+/*
+ * 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.databinding.wire;
+
+import java.util.List;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.core.RuntimeWireProcessorExtension;
+import org.apache.tuscany.databinding.Mediator;
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.wire.InvocationChain;
+
+/**
+ * This processor is responsible to add an interceptor to invocation chain if
+ * the source and target operations have different databinding requirements
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessorExtension {
+    private Mediator mediator;
+
+    public DataBindingRuntimeWireProcessor(Mediator mediator) {
+        super();
+        this.mediator = mediator;
+    }
+
+    public boolean isTransformationRequired(DataType source, DataType target) {
+        if (source == target) {
+            return false;
+        }
+        String sourceDataBinding = source.getDataBinding();
+        String targetDataBinding = target.getDataBinding();
+        if (sourceDataBinding == targetDataBinding) {
+            return false;
+        }
+        if (sourceDataBinding == null || targetDataBinding == null) {
+            return true;
+        }
+        return !sourceDataBinding.equals(targetDataBinding);
+    }
+
+    public boolean isTransformationRequired(Operation source, Operation target) {
+        if (source == target) {
+            return false;
+        }
+
+        // Check output type
+        DataType sourceOutputType = source.getOutputType();
+        DataType targetOutputType = target.getOutputType();
+
+        // Note the target output type is now the source for checking
+        // compatibility
+        if (isTransformationRequired(targetOutputType, sourceOutputType)) {
+            return true;
+        }
+
+        List<DataType> sourceInputType = source.getInputType().getLogical();
+        List<DataType> targetInputType = target.getInputType().getLogical();
+
+        int size = sourceInputType.size();
+        for (int i = 0; i < size; i++) {
+            if (isTransformationRequired(sourceInputType.get(i), targetInputType.get(i))) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private boolean isTransformationRequired(InterfaceContract sourceContract,
+                                             Operation sourceOperation,
+                                             InterfaceContract targetContract,
+                                             Operation targetOperation) {
+        if (targetContract == null) {
+            targetContract = sourceContract;
+        }
+        if (sourceContract == targetContract) {
+            return false;
+        }
+        return isTransformationRequired(sourceOperation, targetOperation);
+    }
+
+    public void process(RuntimeWire wire) {
+        InterfaceContract sourceContract = wire.getSource().getInterfaceContract();
+        InterfaceContract targetContract = wire.getTarget().getInterfaceContract();
+        if (targetContract == null) {
+            targetContract = sourceContract;
+        }
+        if (sourceContract == targetContract) {
+            return;
+        }
+        List<InvocationChain> chains = wire.getInvocationChains();
+        for (InvocationChain chain : chains) {
+            Operation sourceOperation = chain.getSourceOperation();
+            Operation targetOperation = chain.getTargetOperation();
+
+            if (isTransformationRequired(sourceContract, sourceOperation, targetContract, targetOperation)) {
+                // Add the interceptor to the source side because multiple
+                // references can be wired
+                // to the same service
+                DataTransformationInteceptor interceptor = new DataTransformationInteceptor(wire, sourceOperation,
+                                                                              targetOperation);
+                interceptor.setMediator(mediator);
+                chain.addInterceptor(0, interceptor);
+            }
+        }
+
+        // Object targetAddress = UriHelper.getBaseName(source.getUri());
+        List<InvocationChain> callbackChains = wire.getCallbackInvocationChains();
+        if (callbackChains == null) {
+            // callback chains could be null
+            return;
+        }
+
+        for (InvocationChain chain : callbackChains) {
+            Operation sourceOperation = chain.getSourceOperation();
+            Operation targetOperation = chain.getTargetOperation();
+            if (isTransformationRequired(sourceContract, sourceOperation, targetContract, targetOperation)) {
+
+                // Add the interceptor to the source side because multiple
+                // references can be wired
+                // to the same service
+                DataTransformationInteceptor interceptor = new DataTransformationInteceptor(wire, sourceOperation,
+                                                                              targetOperation);
+                interceptor.setMediator(mediator);
+                chain.addInterceptor(0, interceptor);
+            }
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingRuntimeWireProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java (added)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java Thu May  3 16:24:10 2007
@@ -0,0 +1,236 @@
+/*
+ * 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.databinding.wire;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.databinding.DataBinding;
+import org.apache.tuscany.databinding.ExceptionHandler;
+import org.apache.tuscany.databinding.Mediator;
+import org.apache.tuscany.databinding.TransformationException;
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.interfacedef.util.FaultException;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * An interceptor to transform data accross databindings on the wire
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DataTransformationInteceptor implements Interceptor {
+    private Interceptor next;
+
+    private Operation sourceOperation;
+
+    private Operation targetOperation;
+
+    private Mediator mediator;
+
+    public DataTransformationInteceptor(RuntimeWire wire,
+                                 Operation sourceOperation,
+                                 Operation targetOperation) {
+        super();
+        this.sourceOperation = sourceOperation;
+        this.targetOperation = targetOperation;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#getNext()
+     */
+    public Interceptor getNext() {
+        return next;
+    }
+
+    public Message invoke(Message msg) {
+        Object input = transform(msg.getBody(), sourceOperation.getInputType(), targetOperation.getInputType(), false);
+        msg.setBody(input);
+        Message resultMsg = next.invoke(msg);
+        Object result = resultMsg.getBody();
+        if (sourceOperation.isNonBlocking()) {
+            // Not to reset the message body
+            return resultMsg;
+        }
+
+        // FIXME: Should we fix the Operation model so that getOutputType
+        // returns DataType<DataType<T>>?
+        DataType<DataType> targetType =
+            new DataTypeImpl<DataType>(DataBinding.IDL_OUTPUT, Object.class, targetOperation.getOutputType());
+
+        DataType<DataType> sourceType =
+            new DataTypeImpl<DataType>(DataBinding.IDL_OUTPUT, Object.class, sourceOperation.getOutputType());
+
+        if (resultMsg.isFault()) {
+
+            // FIXME: We need to figure out what fault type it is and then
+            // transform it
+            // back the source fault type
+            // throw new InvocationRuntimeException((Throwable) result);
+
+            if ((result instanceof Exception) && !(result instanceof RuntimeException)) {
+                // FIXME: How to match fault data to a fault type for the
+                // operation?
+
+                // If the result is from an InvocationTargetException look at
+                // the actual cause.
+                if (result instanceof InvocationTargetException) {
+                    result = ((InvocationTargetException)result).getCause();
+                }
+                DataType targetDataType = null;
+                for (DataType exType : targetOperation.getFaultTypes()) {
+                    if (((Class)exType.getPhysical()).isInstance(result)) {
+                        if (result instanceof FaultException) {
+                            if (((FaultException)result).isMatchingType(exType.getLogical())) {
+                                targetDataType = exType;
+                                break;
+                            }
+                        } else {
+                            targetDataType = exType;
+                            break;
+                        }
+                    }
+                }
+
+                if (targetDataType == null) {
+                    // Not a business exception
+                    return resultMsg;
+                }
+
+                DataType targetFaultType = getFaultType(targetDataType);
+                if (targetFaultType == null) {
+                    throw new TransformationException("Target fault type cannot be resolved");
+                }
+
+                // FIXME: How to match a source fault type to a target fault
+                // type?
+                DataType sourceDataType = null;
+                DataType sourceFaultType = null;
+                for (DataType exType : sourceOperation.getFaultTypes()) {
+                    DataType faultType = getFaultType(exType);
+                    // Match by the QName (XSD element) of the fault type
+                    if (faultType != null && targetFaultType.getLogical().equals(faultType.getLogical())) {
+                        sourceDataType = exType;
+                        sourceFaultType = faultType;
+                        break;
+                    }
+                }
+
+                if (sourceFaultType == null) {
+                    throw new TransformationException("No matching source fault type is found");
+                }
+
+                Object newResult =
+                    transformException(result, targetDataType, sourceDataType, targetFaultType, sourceFaultType);
+                if (newResult != result) {
+                    resultMsg.setBodyWithFault(newResult);
+                }
+            }
+
+        } else {
+            assert !(result instanceof Throwable) : "Expected messages that are not throwable " + result;
+
+            Object newResult = transform(result, targetType, sourceType, true);
+            if (newResult != result) {
+                resultMsg.setBody(newResult);
+            }
+        }
+
+        return resultMsg;
+    }
+
+    private Object transform(Object source, DataType sourceType, DataType targetType, boolean isResponse) {
+        if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+            return source;
+        }
+        Map<String, Object> metadata = new HashMap<String, Object>();
+        metadata.put("source.operation", isResponse? targetOperation: sourceOperation);
+        metadata.put("target.operation", isResponse? sourceOperation: targetOperation);
+        return mediator.mediate(source, sourceType, targetType, metadata);
+    }
+
+    private DataType getFaultType(DataType exceptionType) {
+        // FIXME: We cannot assume the exception will have a databinding set
+        DataBinding targetDataBinding =
+            mediator.getDataBindings().getDataBinding(exceptionType.getDataBinding());
+        if (targetDataBinding == null) {
+            return null;
+        }
+        ExceptionHandler targetHandler = targetDataBinding.getExceptionHandler();
+        if (targetHandler == null) {
+            return null;
+        }
+        return targetHandler.getFaultType(exceptionType);
+    }
+
+    /**
+     * @param source The source exception
+     * @param sourceExType The data type for the source exception
+     * @param targetExType The data type for the target exception
+     * @param sourceType The fault type for the source
+     * @param targetType The fault type for the target
+     * @return
+     */
+    private Object transformException(Object source,
+                                      DataType sourceExType,
+                                      DataType targetExType,
+                                      DataType sourceType,
+                                      DataType targetType) {
+        if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+            return source;
+        }
+        Map<String, Object> metadata = new HashMap<String, Object>();
+        metadata.put("source.operation", targetOperation);
+        metadata.put("target.operation", sourceOperation);
+
+        DataType<DataType> eSourceDataType =
+            new DataTypeImpl<DataType>("idl:fault", sourceExType.getPhysical(), sourceType);
+        DataType<DataType> eTargetDataType =
+            new DataTypeImpl<DataType>("idl:fault", targetExType.getPhysical(), targetType);
+
+        return mediator.mediate(source, eSourceDataType, eTargetDataType, metadata);
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#isOptimizable()
+     */
+    public boolean isOptimizable() {
+        return false;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#setNext(org.apache.tuscany.spi.wire.Interceptor)
+     */
+    public void setNext(Interceptor next) {
+        this.next = next;
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWire.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWire.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWire.java Thu May  3 16:24:10 2007
@@ -22,8 +22,7 @@
 import java.util.List;
 
 import org.apache.tuscany.assembly.Binding;
-import org.apache.tuscany.assembly.ComponentReference;
-import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.interfacedef.InterfaceContract;
 import org.apache.tuscany.spi.wire.InvocationChain;
 
 /**
@@ -33,31 +32,36 @@
  * @version $Rev$ $Date$
  */
 public interface RuntimeWire {
-    /**
-     * Get the source of the wire
-     * 
-     * @return
-     */
-    ComponentReference getSource();
 
     /**
-     * Get the reference binding
-     * 
-     * @return
+     * The source metadata for a runtime wire
      */
-    Binding getSourceBinding();
+    public interface Source {
+        RuntimeComponent getComponent();
 
-    /**
-     * Get the target of the wire. It will be null if the binding is
-     * 
-     * @return
-     */
-    ComponentService getTarget();
+        RuntimeComponentReference getComponentReference();
+
+        Binding getBinding();
+
+        InterfaceContract getInterfaceContract();
+    }
 
     /**
-     * @return
+     * The target metadata for a runtime wire
      */
-    Binding getTargetBinding();
+    public interface Target {
+        RuntimeComponent getComponent();
+
+        RuntimeComponentService getComponentService();
+
+        Binding getBinding();
+
+        InterfaceContract getInterfaceContract();
+    }
+
+    Source getSource();
+
+    Target getTarget();
 
     /**
      * Returns the invocation chains for service operations associated with the

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java Thu May  3 16:24:10 2007
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+/**
+ * Implementations are called after wires are decorated with policy and before they are connected.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeWireProcessorExtension {
+
+    /**
+     * Process the runtime wire to add interceptors
+     * 
+     * @param wire
+     */
+    void process(RuntimeWire wire);
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeWireProcessorExtension.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java Thu May  3 16:24:10 2007
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * Acts as a delegating <code>WireProcessorExtensionPoint</code>, delegating
+ * processing of wires after policies have been applied and source an targets
+ * have been connected.
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface WireProcessorExtensionPoint extends RuntimeWireProcessorExtension {
+
+    /**
+     * Registers a wire-processor in the runtime
+     * 
+     * @param processor the processor to register
+     */
+    void register(RuntimeWireProcessorExtension processor);
+
+    /**
+     * De-registers a wire-processor in the runtime
+     * 
+     * @param processor the processor to de-register
+     */
+    void unregister(RuntimeWireProcessorExtension processor);
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/WireProcessorExtensionPoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java Thu May  3 16:24:10 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.invocation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.core.RuntimeWireProcessorExtension;
+import org.apache.tuscany.core.WireProcessorExtensionPoint;
+
+/**
+ * The default implementation of a <code>WireProcessorExtensionPoint</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWireProcessorExtensionPoint implements WireProcessorExtensionPoint {
+
+    private final List<RuntimeWireProcessorExtension> processors = new ArrayList<RuntimeWireProcessorExtension>();
+
+    public void process(RuntimeWire wire) {
+        for (RuntimeWireProcessorExtension processor : processors) {
+            processor.process(wire);
+        }
+    }
+
+    public void register(RuntimeWireProcessorExtension processor) {
+        processors.add(processor);
+    }
+
+    public void unregister(RuntimeWireProcessorExtension processor) {
+        processors.remove(processor);
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/DefaultWireProcessorExtensionPoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java Thu May  3 16:24:10 2007
@@ -44,6 +44,7 @@
 import org.apache.tuscany.core.ScopedImplementationProvider;
 import org.apache.tuscany.core.ServiceBindingActivator;
 import org.apache.tuscany.core.ServiceBindingProvider;
+import org.apache.tuscany.core.WireProcessorExtensionPoint;
 import org.apache.tuscany.core.component.WorkContextImpl;
 import org.apache.tuscany.core.wire.InvocationChainImpl;
 import org.apache.tuscany.core.wire.NonBlockingInterceptor;
@@ -69,7 +70,7 @@
     private InterfaceContractMapper interfaceContractMapper;
     private WorkContext workContext = new WorkContextImpl();
     private WorkScheduler workScheduler = new Jsr237WorkScheduler(new ThreadPoolWorkManager(10));
-    private WirePostProcessorRegistry wirePostProcessorRegistry;
+    private WireProcessorExtensionPoint wireProcessorExtensionPoint;
 
     /**
      * @param assemblyFactory
@@ -82,13 +83,13 @@
                                      InterfaceContractMapper interfaceContractMapper,
                                      WorkContext workContext,
                                      WorkScheduler workScheduler,
-                                     WirePostProcessorRegistry wirePostProcessorRegistry) {
+                                     WireProcessorExtensionPoint wireProcessorExtensionPoint) {
         super();
         this.assemblyFactory = assemblyFactory;
         this.interfaceContractMapper = interfaceContractMapper;
         this.workContext = workContext;
         this.workScheduler = workScheduler;
-        this.wirePostProcessorRegistry = wirePostProcessorRegistry;
+        this.wireProcessorExtensionPoint = wireProcessorExtensionPoint;
     }
 
     /**
@@ -232,13 +233,22 @@
         if (!(reference instanceof RuntimeComponentReference)) {
             return;
         }
-        RuntimeComponentReference wireSource = (RuntimeComponentReference)reference;
-        InterfaceContract sourceContract = getInterfaceContract(reference, binding);
+        RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
+        InterfaceContract bindingContract = getInterfaceContract(reference, binding);
 
         if (!(binding instanceof SCABinding)) {
-            RuntimeWire wire = new RuntimeWireImpl(reference, binding);
+            InterfaceContract sourceContract = reference.getInterfaceContract();
+            
+            // Component Reference --> External Service
+            RuntimeWire.Source wireSource = new RuntimeWireImpl.SourceImpl((RuntimeComponent)component,
+                                                                           (RuntimeComponentReference)reference,
+                                                                           binding, sourceContract);
+
+            RuntimeWire.Target wireTarget = new RuntimeWireImpl.TargetImpl(null, null, binding, bindingContract);
+            RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
+
             for (Operation operation : sourceContract.getInterface().getOperations()) {
-                Operation targetOperation = operation;
+                Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
                 InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                 if (operation.isNonBlocking()) {
                     chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
@@ -248,7 +258,7 @@
             }
             if (sourceContract.getCallbackInterface() != null) {
                 for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
-                    Operation targetOperation = operation;
+                    Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(), operation);
                     InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                     if (operation.isNonBlocking()) {
                         chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
@@ -257,7 +267,8 @@
                     wire.getCallbackInvocationChains().add(chain);
                 }
             }
-            wireSource.addRuntimeWire(wire);
+            runtimeRef.addRuntimeWire(wire);
+            wireProcessorExtensionPoint.process(wire);
         }
         for (ComponentService service : reference.getTargets()) {
             Component target = null;
@@ -266,9 +277,19 @@
                 target = scaBinding.getComponent();
             }
 
-            RuntimeWire wire = new RuntimeWireImpl(reference, service);
             InterfaceContract targetContract = service.getInterfaceContract();
-            for (Operation operation : sourceContract.getInterface().getOperations()) {
+
+            RuntimeWire.Source wireSource = new RuntimeWireImpl.SourceImpl((RuntimeComponent)component,
+                                                                           (RuntimeComponentReference)reference,
+                                                                           binding, bindingContract);
+
+            RuntimeWire.Target wireTarget = new RuntimeWireImpl.TargetImpl((RuntimeComponent)target,
+                                                                           (RuntimeComponentService)service, binding,
+                                                                           targetContract);
+
+            RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
+
+            for (Operation operation : bindingContract.getInterface().getOperations()) {
                 Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
                 InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                 if (operation.isNonBlocking()) {
@@ -280,8 +301,8 @@
                 }
                 wire.getInvocationChains().add(chain);
             }
-            if (sourceContract.getCallbackInterface() != null) {
-                for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
+            if (bindingContract.getCallbackInterface() != null) {
+                for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
                     Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(),
                                                                             operation);
                     InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
@@ -294,7 +315,8 @@
                 }
             }
 
-            wireSource.addRuntimeWire(wire);
+            runtimeRef.addRuntimeWire(wire);
+            wireProcessorExtensionPoint.process(wire);
         }
     }
 
@@ -329,12 +351,18 @@
         if (!(service instanceof RuntimeComponentService)) {
             return;
         }
-        RuntimeComponentService wireSource = (RuntimeComponentService)service;
+        RuntimeComponentService runtimeService = (RuntimeComponentService)service;
 
         InterfaceContract targetContract = service.getInterfaceContract();
         InterfaceContract sourceContract = getInterfaceContract(service, binding);
 
-        RuntimeWire wire = new RuntimeWireImpl(null, service);
+        RuntimeWire.Source wireSource = new RuntimeWireImpl.SourceImpl(null, null, binding, sourceContract);
+
+        RuntimeWire.Target wireTarget = new RuntimeWireImpl.TargetImpl((RuntimeComponent)component,
+                                                                       (RuntimeComponentService)service, binding,
+                                                                       targetContract);
+
+        RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
 
         for (Operation operation : sourceContract.getInterface().getOperations()) {
             Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
@@ -361,7 +389,8 @@
             }
         }
 
-        wireSource.addRuntimeWire(wire);
+        runtimeService.addRuntimeWire(wire);
+        wireProcessorExtensionPoint.process(wire);
     }
 
     /**

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java Thu May  3 16:24:10 2007
@@ -39,8 +39,9 @@
 import org.apache.tuscany.contribution.Contribution;
 import org.apache.tuscany.core.ExtensionPointRegistry;
 import org.apache.tuscany.core.ModuleActivator;
-import org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl;
+import org.apache.tuscany.core.WireProcessorExtensionPoint;
 import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.invocation.DefaultWireProcessorExtensionPoint;
 import org.apache.tuscany.core.invocation.JDKProxyService;
 import org.apache.tuscany.core.scope.AbstractScopeContainer;
 import org.apache.tuscany.core.scope.CompositeScopeContainer;
@@ -61,7 +62,6 @@
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.component.WorkContextTunnel;
 import org.apache.tuscany.spi.services.work.WorkScheduler;
-import org.apache.tuscany.spi.wire.WirePostProcessorRegistry;
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.Constants;
 
@@ -119,25 +119,26 @@
         extensionPointRegistry.addExtensionPoint(WorkContext.class, workContext);
 
         WorkContextTunnel.setThreadWorkContext(workContext);
-        
-        extensionPointRegistry.addExtensionPoint(ProxyFactory.class, new JDKProxyService(workContext, interfaceContractMapper));
+
+        extensionPointRegistry.addExtensionPoint(ProxyFactory.class, new JDKProxyService(workContext,
+                                                                                         interfaceContractMapper));
 
         workManager = new ThreadPoolWorkManager(10);
         WorkScheduler workScheduler = new Jsr237WorkScheduler(workManager);
 
-        WirePostProcessorRegistry wirePostProcessorRegistry = new WirePostProcessorRegistryImpl();
-        extensionPointRegistry.addExtensionPoint(WirePostProcessorRegistry.class, wirePostProcessorRegistry);
+        WireProcessorExtensionPoint wireProcessorExtensionPoint = new DefaultWireProcessorExtensionPoint();
+        extensionPointRegistry.addExtensionPoint(WireProcessorExtensionPoint.class, wireProcessorExtensionPoint);
 
         // Create the composite activator
         compositeActivator = new DefaultCompositeActivator(assemblyFactory, interfaceContractMapper, workContext,
-                                                           workScheduler, wirePostProcessorRegistry);
+                                                           workScheduler, wireProcessorExtensionPoint);
 
         // Create the default SCA domain
         domain = assemblyFactory.createComposite();
         domain.setName(new QName(Constants.SCA_NS, "sca.domain"));
         domain.setURI("sca://local/");
     }
-    
+
     public <B> B locateService(Class<B> businessInterface, String componentName, String serviceName) {
         return getComponentContext(componentName).createSelfReference(businessInterface, serviceName).getService();
     }
@@ -145,7 +146,7 @@
     public <B> B locateService(Class<B> businessInterface, String componentName) {
         return getComponentContext(componentName).createSelfReference(businessInterface).getService();
     }
-    
+
     public void start() throws ActivationException {
         activators = getInstances(hostClassLoader, ModuleActivator.class);
         for (ModuleActivator activator : activators) {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java Thu May  3 16:24:10 2007
@@ -23,20 +23,20 @@
 import java.util.List;
 
 import org.apache.tuscany.assembly.Binding;
-import org.apache.tuscany.assembly.ComponentReference;
-import org.apache.tuscany.assembly.ComponentService;
-import org.apache.tuscany.assembly.SCABinding;
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentReference;
+import org.apache.tuscany.core.RuntimeComponentService;
 import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.interfacedef.InterfaceContract;
 import org.apache.tuscany.spi.wire.InvocationChain;
 
 /**
  * @version $Rev$ $Date$
  */
 public class RuntimeWireImpl implements RuntimeWire {
-    private ComponentReference source;
-    private Binding sourceBinding;
-    private ComponentService target;
-    private Binding targetBinding;
+    private Source wireSource;
+    private Target wireTarget;
+
     private final List<InvocationChain> chains = new ArrayList<InvocationChain>();
     private final List<InvocationChain> callbackChains = new ArrayList<InvocationChain>();
 
@@ -44,33 +44,10 @@
      * @param source
      * @param target
      */
-    public RuntimeWireImpl(ComponentReference source, ComponentService target) {
+    public RuntimeWireImpl(Source source, Target target) {
         super();
-        this.source = source;
-        this.target = target;
-    }
-
-    /**
-     * Create a wire for a promoted reference
-     * @param source
-     * @param sourceBinding
-     */
-    public RuntimeWireImpl(ComponentReference source,
-                           Binding sourceBinding) {
-        this.source = source;
-        this.sourceBinding = sourceBinding;
-        assert !(sourceBinding instanceof SCABinding);
-    }
-    
-    public RuntimeWireImpl(ComponentReference source,
-                           Binding sourceBinding,
-                           ComponentService target,
-                           Binding targetBinding) {
-        super();
-        this.source = source;
-        this.sourceBinding = sourceBinding;
-        this.target = target;
-        this.targetBinding = targetBinding;
+        this.wireSource = source;
+        this.wireTarget = target;
     }
 
     public List<InvocationChain> getCallbackInvocationChains() {
@@ -81,33 +58,96 @@
         return chains;
     }
 
-    public ComponentReference getSource() {
-        return source;
-    }
-
-    public ComponentService getTarget() {
-        return target;
-    }
-
-    public Binding getSourceBinding() {
-        return sourceBinding;
-    }
-
-    public void setSourceBinding(Binding sourceBinding) {
-        this.sourceBinding = sourceBinding;
+    public boolean isOptimizable() {
+        return false;
     }
 
-    public Binding getTargetBinding() {
-        return targetBinding;
+    public static class SourceImpl implements RuntimeWire.Source {
+        private RuntimeComponent component;
+        private RuntimeComponentReference componentReference;
+        private Binding binding;
+        private InterfaceContract interfaceContract;
+
+        /**
+         * @param component
+         * @param componentReference
+         * @param binding
+         * @param interfaceContract
+         */
+        public SourceImpl(RuntimeComponent component,
+                          RuntimeComponentReference componentReference,
+                          Binding binding,
+                          InterfaceContract interfaceContract) {
+            super();
+            this.component = component;
+            this.componentReference = componentReference;
+            this.binding = binding;
+            this.interfaceContract = interfaceContract;
+        }
+
+        public Binding getBinding() {
+            return binding;
+        }
+
+        public RuntimeComponent getComponent() {
+            return component;
+        }
+
+        public RuntimeComponentReference getComponentReference() {
+            return componentReference;
+        }
+
+        public InterfaceContract getInterfaceContract() {
+            return interfaceContract;
+        }
+    }
+
+    public static class TargetImpl implements RuntimeWire.Target {
+        private RuntimeComponent component;
+        private RuntimeComponentService componentService;
+        private Binding binding;
+        private InterfaceContract interfaceContract;
+
+        /**
+         * @param component
+         * @param componentService
+         * @param binding
+         * @param interfaceContract
+         */
+        public TargetImpl(RuntimeComponent component,
+                          RuntimeComponentService componentService,
+                          Binding binding,
+                          InterfaceContract interfaceContract) {
+            super();
+            this.component = component;
+            this.componentService = componentService;
+            this.binding = binding;
+            this.interfaceContract = interfaceContract;
+        }
+
+        public Binding getBinding() {
+            return binding;
+        }
+
+        public RuntimeComponent getComponent() {
+            return component;
+        }
+
+        public RuntimeComponentService getComponentService() {
+            return componentService;
+        }
+
+        public InterfaceContract getInterfaceContract() {
+            return interfaceContract;
+        }
     }
 
-    public void setTargetBinding(Binding targetBinding) {
-        this.targetBinding = targetBinding;
+    public Source getSource() {
+        return wireSource;
     }
 
-    public boolean isOptimizable() {
-        // TODO Auto-generated method stub
-        return false;
+    public Target getTarget() {
+        return wireTarget;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/PojoAtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/PojoAtomicComponent.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/PojoAtomicComponent.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/PojoAtomicComponent.java Thu May  3 16:24:10 2007
@@ -157,7 +157,7 @@
     }
 
     public void attachWire(RuntimeWire wire) {
-        String referenceName = wire.getSource().getName();
+        String referenceName = wire.getSource().getComponentReference().getName();
         List<RuntimeWire> wireList = wires.get(referenceName);
         if (wireList == null) {
             wireList = new ArrayList<RuntimeWire>();
@@ -178,7 +178,7 @@
 
     public void attachWires(List<RuntimeWire> attachWires) {
         assert attachWires.size() > 0;
-        String referenceName = attachWires.get(0).getSource().getName();
+        String referenceName = attachWires.get(0).getSource().getComponentReference().getName();
         List<RuntimeWire> wireList = wires.get(referenceName);
         if (wireList == null) {
             wireList = new ArrayList<RuntimeWire>();

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/DefaultEchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/DefaultEchoBindingFactory.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/DefaultEchoBindingFactory.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/DefaultEchoBindingFactory.java Thu May  3 16:24:10 2007
@@ -19,10 +19,15 @@
 
 package echo;
 
+/**
+ * A factory for the sample Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
 public class DefaultEchoBindingFactory implements EchoBindingFactory {
 
     public EchoBinding createEchoBinding() {
-        return new EchoBindingImpl();
+        return new EchoBindingProvider();
     }
 
 }

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBinding.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBinding.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBinding.java Thu May  3 16:24:10 2007
@@ -19,8 +19,17 @@
 
 package echo;
 
+import static org.osoa.sca.Constants.SCA_NS;
+
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.assembly.Binding;
 
+/**
+ * A model for the sample Echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
 public interface EchoBinding extends Binding {
-
+    QName BINDING_ECHO = new QName(SCA_NS, "binding.echo");
 }

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingFactory.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingFactory.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingFactory.java Thu May  3 16:24:10 2007
@@ -19,7 +19,13 @@
 
 package echo;
 
+/**
+ * A factory for the sample Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
 public interface EchoBindingFactory {
+    
     /**
      * Creates a new Echo binding.
      * 

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingImpl.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingImpl.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingImpl.java Thu May  3 16:24:10 2007
@@ -19,10 +19,59 @@
 
 package echo;
 
-import org.apache.tuscany.assembly.impl.BindingImpl;
+import java.util.Collections;
+import java.util.List;
 
-public class EchoBindingImpl extends BindingImpl implements EchoBinding {
-    public Object clone() {
-        return this;
+import org.apache.tuscany.policy.Intent;
+import org.apache.tuscany.policy.PolicySet;
+
+/**
+ * Implementation of the Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingImpl implements EchoBinding {
+    
+    private String name;
+    private String uri;
+
+    public String getName() {
+        return name;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public List<PolicySet> getPolicySets() {
+        // The sample binding does not support policies
+        return Collections.emptyList();
+    }
+
+    public List<Intent> getRequiredIntents() {
+        // The sample binding does not support policies
+        return Collections.emptyList();
     }
+    
+    public List<Object> getExtensions() {
+        // The sample binding does not support extensions
+        return Collections.emptyList();
+    }
+
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        // The sample binding is always resolved
+    }
+
 }

Added: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java (added)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java Thu May  3 16:24:10 2007
@@ -0,0 +1,69 @@
+/*
+ * 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 echo;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * Interceptor for the sample echo binding.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingInterceptor implements Interceptor {
+    private Interceptor next;
+
+    private Object echo(Object[] args) throws InvocationTargetException {
+        // echo back the result, a real binding would invoke some API for flowing the request
+        return args[0];
+    }
+
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        try {
+            Object resp = echo((Object[])msg.getBody());
+            msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setBodyWithFault(e.getCause());
+        } catch (Throwable e) {
+            msg.setBodyWithFault(e);
+        }
+        return msg;
+    }  
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+    public Interceptor getNext() {
+        return next;
+    }
+
+    public void setNext(Interceptor next) {
+        this.next = next;
+    }
+
+    public boolean isOptimizable() {
+        return false;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProcessor.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProcessor.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProcessor.java Thu May  3 16:24:10 2007
@@ -27,9 +27,13 @@
 import org.apache.tuscany.contribution.resolver.ArtifactResolver;
 import org.apache.tuscany.contribution.service.ContributionReadException;
 import org.apache.tuscany.contribution.service.ContributionResolveException;
-import org.apache.tuscany.contribution.service.ContributionWireException;
 import org.apache.tuscany.contribution.service.ContributionWriteException;
 
+/**
+ * A processor for <binding.echo> elements.
+ * 
+ * @version $Rev$ $Date$
+ */
 public class EchoBindingProcessor implements StAXArtifactProcessor<EchoBinding> {
     private final EchoBindingFactory factory;
 
@@ -42,7 +46,7 @@
     }
 
     public QName getArtifactType() {
-        return EchoConstants.BINDING_ECHO;
+        return EchoBinding.BINDING_ECHO;
     }
 
     public Class<EchoBinding> getModelType() {

Added: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java?view=auto&rev=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java (added)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java Thu May  3 16:24:10 2007
@@ -0,0 +1,89 @@
+/*
+ * 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 echo;
+
+import java.net.URI;
+
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.ComponentReference;
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.core.ReferenceBindingActivator;
+import org.apache.tuscany.core.ReferenceBindingProvider;
+import org.apache.tuscany.core.RuntimeComponentService;
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.core.ServiceBindingActivator;
+import org.apache.tuscany.core.ServiceBindingProvider;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+
+/**
+ * Implementation of the Echo binding provider.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingProvider extends EchoBindingImpl implements ReferenceBindingActivator,
+    ReferenceBindingProvider, ServiceBindingActivator, ServiceBindingProvider {
+
+    public Interceptor createInterceptor(Component component,
+                                         ComponentReference reference,
+                                         Operation operation,
+                                         boolean isCallback) {
+        if (isCallback) {
+            throw new UnsupportedOperationException();
+        } else {
+            return new EchoBindingInterceptor();
+        }
+    }
+
+    public InterfaceContract getBindingInterfaceContract(ComponentReference reference) {
+        return reference.getInterfaceContract();
+    }
+
+    public void start(Component component, ComponentReference reference) {
+    }
+
+    public void stop(Component component, ComponentReference reference) {
+    }
+
+    public InterfaceContract getBindingInterfaceContract(ComponentService service) {
+        return service.getInterfaceContract();
+    }
+
+    public void start(Component component, ComponentService service) {
+        URI uri = URI.create(component.getURI() + "/" + getName());
+        setURI(uri.toString());
+        RuntimeComponentService componentService = (RuntimeComponentService) service;
+        RuntimeWire wire = componentService.getRuntimeWires().get(0);
+        InvocationChain chain = wire.getInvocationChains().get(0);
+        // Register with the hosting server
+        EchoServer.getServer().register(new EchoService(chain.getHeadInterceptor()), uri);
+    }
+
+    public void stop(Component component, ComponentService service) {
+        // Register with the hosting server
+        EchoServer.getServer().unregister(URI.create(getURI()));
+    }
+
+    public Object clone() {
+        return this;
+    }
+}

Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoModuleActivator.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoModuleActivator.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoModuleActivator.java Thu May  3 16:24:10 2007
@@ -24,12 +24,14 @@
 import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.core.ExtensionPointRegistry;
 import org.apache.tuscany.core.ModuleActivator;
-import org.apache.tuscany.spi.builder.BuilderRegistry;
-
 
+/**
+ * A module activator for the sample Echo binding extension.
+ *
+ * @version $Rev$ $Date$
+ */
 public class EchoModuleActivator implements ModuleActivator {
     private final EchoBindingProcessor echoBindingProcessor = new EchoBindingProcessor();
-    private final EchoBindingBuilder echoBindingBuilder = new EchoBindingBuilder();
 
     public Map<Class, Object> getExtensionPoints() {
         // No extensionPoints being contributed here
@@ -38,24 +40,19 @@
 
     public void start(ExtensionPointRegistry registry) {
 
-        // Add the EchoProcessor to the proper registry
-        StAXArtifactProcessorExtensionPoint artifactProcessorRegistry = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
-        artifactProcessorRegistry.addArtifactProcessor(echoBindingProcessor);
-        
-        // Add the EchoBuilder to the proper registry
-        BuilderRegistry builderRegistry = registry.getExtensionPoint(BuilderRegistry.class);
-        echoBindingBuilder.setBuilderRegistry(builderRegistry);
-        echoBindingBuilder.init();
-        builderRegistry.register(EchoBinding.class, echoBindingBuilder);
-        
+        // Add the EchoProcessor extension
+        StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        processors.addArtifactProcessor(echoBindingProcessor);
+       
         // Start the Echo server
         EchoServer.start();
     }
 
     public void stop(ExtensionPointRegistry registry) {
-        // Remove the EchoProcessor from the proper registry
-        StAXArtifactProcessorExtensionPoint artifactProcessorRegistry = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
-        artifactProcessorRegistry.removeArtifactProcessor(echoBindingProcessor);
+        
+        // Remove the EchoProcessor from the registry
+        StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        processors.removeArtifactProcessor(echoBindingProcessor);
 
         EchoServer.stop();
     }

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoServer.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoServer.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoServer.java Thu May  3 16:24:10 2007
@@ -25,30 +25,31 @@
 import java.util.Map;
 
 /**
- * EchoTransport
- *
+ * A sample Echo server, showing how to integrate service bindings. 
+ * 
  * @version $Rev$ $Date$
  */
 public class EchoServer {
-    
+
     public static EchoServer server;
-    
-    private Map<URI, EchoService> services = new HashMap<URI, EchoService>(); 
-    
+
+    private Map<URI, EchoService> services = new HashMap<URI, EchoService>();
+
     public static void start() {
         server = new EchoServer();
     }
-    
+
     public static void stop() {
         server = null;
     }
-    
+
     public static EchoServer getServer() {
         return server;
     }
 
     /**
      * Register a service under the given name.
+     * 
      * @param service
      * @param name
      */
@@ -56,15 +57,19 @@
         services.put(name, service);
     }
 
+    public void unregister(URI name) {
+        services.remove(name);
+    }
+
     /**
      * Dispatch an incoming interaction to the corresponding service.
+     * 
      * @param uri
      * @param input
      * @return
      */
-    public String sendReceive(String composite, String service, String input) throws InvocationTargetException {
-        URI uri = URI.create("/" + composite + "/#" + service);
-        return services.get(uri).sendReceive(input);
+    public String sendReceive(String uri, String input) throws InvocationTargetException {
+        return services.get(URI.create(uri)).sendReceive(input);
     }
 
 }

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java Thu May  3 16:24:10 2007
@@ -19,69 +19,40 @@
 package echo;
 
 import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
 
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.spi.CoreRuntimeException;
-import org.apache.tuscany.spi.component.WorkContextTunnel;
-import org.apache.tuscany.spi.component.TargetInvokerCreationException;
 import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.extension.ServiceBindingExtension;
+import org.apache.tuscany.spi.component.WorkContextTunnel;
 import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationChain;
 import org.apache.tuscany.spi.wire.Message;
 import org.apache.tuscany.spi.wire.MessageImpl;
-import org.apache.tuscany.spi.wire.TargetInvoker;
 
 /**
  * @version $Rev$ $Date$
  */
-public class EchoService extends ServiceBindingExtension {
-    
-    public EchoService(URI name) throws CoreRuntimeException {
-        super(name);
-        
-        // Register with the hosting server
-        EchoServer.getServer().register(this, name);
-    }
+public class EchoService {
+    private Interceptor interceptor;
 
-    public QName getBindingType() {
-        return EchoConstants.BINDING_ECHO;
+    public EchoService(Interceptor interceptor) {
+        super();
+        this.interceptor = interceptor;
     }
 
-    public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean isCallback) throws TargetInvokerCreationException {
-        //TODO Show support for callbacks in this sample
-        throw new UnsupportedOperationException();
-    }
+    public String sendReceive(String input) throws InvocationTargetException {
 
-    String sendReceive(String input) throws InvocationTargetException {
-        
-        // Get the invocation chain for the first operation in the service interface
-        InvocationChain chain = wire.getInvocationChains().get(0);
-        Interceptor headInterceptor = chain.getHeadInterceptor();
         WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
-        if (headInterceptor == null) {
-            // short-circuit the dispatch and invoke the target directly
-            TargetInvoker targetInvoker = chain.getTargetInvoker();
-            return (String)targetInvoker.invokeTarget(new Object[]{input}, TargetInvoker.NONE, workContext);
-        } else {
-
-            Message msg = new MessageImpl();
-            msg.setTargetInvoker(chain.getTargetInvoker());
-            msg.setBody(new Object[]{input});
-            msg.setWorkContext(workContext);
-            Message resp;
-
-            // dispatch and get the response
-            resp = headInterceptor.invoke(msg);
-            Object body = resp.getBody();
-            if (resp.isFault()) {
-                throw new InvocationTargetException((Throwable) body);
-            }
-            return (String)body;
+
+        Message msg = new MessageImpl();
+        msg.setBody(new Object[] {input});
+        msg.setWorkContext(workContext);
+        Message resp;
+
+        // dispatch and get the response
+        resp = interceptor.invoke(msg);
+        Object body = resp.getBody();
+        if (resp.isFault()) {
+            throw new InvocationTargetException((Throwable)body);
         }
+        return (String)body;
     }
-    
+
 }

Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/test/java/echo/EchoDataBindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/test/java/echo/EchoDataBindingTestCase.java?view=diff&rev=535028&r1=535027&r2=535028
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/test/java/echo/EchoDataBindingTestCase.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/test/java/echo/EchoDataBindingTestCase.java Thu May  3 16:24:10 2007
@@ -20,7 +20,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.host.embedded.SCARuntime;
+import org.apache.tuscany.host.embedded.SCARuntimeActivator;
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.ServiceReference;
 
@@ -31,19 +31,18 @@
 
     @Override
     protected void setUp() throws Exception {
-        SCARuntime.start("EchoDataBinding.composite");
+        SCARuntimeActivator.start("EchoDataBinding.composite");
     }
 
     @Override
     protected void tearDown() throws Exception {
-        SCARuntime.stop();
+        SCARuntimeActivator.stop();
     }
 
     protected Interface1 componentA;
 
     public void testTransform() {
- // TODO: fails due to trying to instantiate an OMElement
-        ComponentContext context = SCARuntime.getComponentContext("ComponentA");
+        ComponentContext context = SCARuntimeActivator.getComponentContext("ComponentA");
         ServiceReference<Interface1> ref = context.createSelfReference(Interface1.class);
         componentA = ref.getService();
         componentA.call("<message><foo>123</foo></message>");



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