You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/13 21:43:02 UTC

svn commit: r528626 - in /incubator/tuscany/java/sca/samples/echo-binding/src: main/java/echo/ main/java/org/ main/resources/META-INF/services/ test/java/echo/ test/java/org/ test/resources/

Author: jsdelfino
Date: Fri Apr 13 12:43:01 2007
New Revision: 528626

URL: http://svn.apache.org/viewvc?view=rev&rev=528626
Log:
Starting to add service binding support and a test case for it.

Added:
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/DefaultEchoBindingFactory.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBinding.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingBuilder.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingFactory.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingImpl.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingProcessor.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoConstants.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoInvoker.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoModuleActivator.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoReference.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoServer.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoService.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java   (with props)
    incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java   (with props)
Removed:
    incubator/tuscany/java/sca/samples/echo-binding/src/main/java/org/
    incubator/tuscany/java/sca/samples/echo-binding/src/test/java/org/
Modified:
    incubator/tuscany/java/sca/samples/echo-binding/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
    incubator/tuscany/java/sca/samples/echo-binding/src/test/resources/EchoBinding.composite

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/DefaultEchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/DefaultEchoBindingFactory.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/DefaultEchoBindingFactory.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/DefaultEchoBindingFactory.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+public class DefaultEchoBindingFactory implements EchoBindingFactory {
+
+    public EchoBinding createEchoBinding() {
+        return new EchoBindingImpl();
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBinding.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBinding.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBinding.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,26 @@
+/*
+ * 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 org.apache.tuscany.assembly.Binding;
+
+public interface EchoBinding extends Binding {
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingBuilder.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingBuilder.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingBuilder.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.CompositeReference;
+import org.apache.tuscany.assembly.CompositeService;
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingBuilder extends BindingBuilderExtension<EchoBinding> {
+    @Override
+    public ServiceBinding build(CompositeService serviceDefinition,
+                                EchoBinding bindingDefinition,
+                                DeploymentContext context) throws BuilderException {
+        return new EchoService(URI.create(context.getComponentId() + "#" + serviceDefinition.getName()));
+    }
+
+    @Override
+    public ReferenceBinding build(CompositeReference referenceDefinition,
+                                  EchoBinding bindingDefinition,
+                                  DeploymentContext context) throws BuilderException {
+        URI targetURI = bindingDefinition.getURI() != null ? URI.create(bindingDefinition.getURI()) : null;
+        return new EchoReference(URI.create(context.getComponentId() + "#" + referenceDefinition.getName()), targetURI);
+    }
+
+    @Override
+    protected Class<EchoBinding> getBindingType() {
+        return EchoBinding.class;
+    }
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingFactory.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingFactory.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingFactory.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+public interface EchoBindingFactory {
+    /**
+     * Creates a new Echo binding.
+     * 
+     * @return a new Echi binding
+     */
+    EchoBinding createEchoBinding();
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingImpl.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingImpl.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingImpl.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,28 @@
+/*
+ * 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 org.apache.tuscany.assembly.impl.BindingImpl;
+
+public class EchoBindingImpl extends BindingImpl implements EchoBinding {
+    public Object clone() {
+        return this;
+    }
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingProcessor.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingProcessor.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoBindingProcessor.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
+import org.apache.tuscany.services.spi.contribution.ContributionReadException;
+import org.apache.tuscany.services.spi.contribution.ContributionResolveException;
+import org.apache.tuscany.services.spi.contribution.ContributionWireException;
+import org.apache.tuscany.services.spi.contribution.ContributionWriteException;
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessor;
+
+public class EchoBindingProcessor implements StAXArtifactProcessor<EchoBinding> {
+    private final EchoBindingFactory factory;
+
+    public EchoBindingProcessor() {
+        this.factory = new DefaultEchoBindingFactory();
+    }
+
+    public EchoBindingProcessor(EchoBindingFactory factory) {
+        this.factory = factory;
+    }
+
+    public QName getArtifactType() {
+        return EchoConstants.BINDING_ECHO;
+    }
+
+    public Class<EchoBinding> getModelType() {
+        return EchoBinding.class;
+    }
+
+    public EchoBinding read(XMLStreamReader reader) throws ContributionReadException {
+        String uri = reader.getAttributeValue(null, "uri");
+        EchoBinding echoBinding = factory.createEchoBinding();
+        if (uri != null) {
+            echoBinding.setURI(uri.trim());
+        }
+        return echoBinding;
+    }
+
+    public void write(EchoBinding echoBinding, XMLStreamWriter writer) throws ContributionWriteException {
+        // TODO Auto-generated method stub
+    }
+
+    public void resolve(EchoBinding echoBinding, ArtifactResolver resolver) throws ContributionResolveException {
+        // TODO Auto-generated method stub
+    }
+
+    public void wire(EchoBinding echoBinding) throws ContributionWireException {
+        // TODO Auto-generated method stub
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoConstants.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoConstants.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoConstants.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,28 @@
+/*
+ * 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 static org.osoa.sca.Constants.SCA_NS;
+
+import javax.xml.namespace.QName;
+
+public interface EchoConstants {
+    QName BINDING_ECHO = new QName(SCA_NS, "binding.echo");
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoInvoker.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoInvoker.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoInvoker.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package echo;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoInvoker implements TargetInvoker {
+
+    private boolean cacheable;
+
+    public boolean isCacheable() {
+        return cacheable;
+    }
+
+    public void setCacheable(boolean cacheable) {
+        this.cacheable = cacheable;
+    }
+
+    public boolean isOptimizable() {
+        return isCacheable();
+    }
+
+    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException {
+        // echo back the result, a real binding would invoke some API for flowing the request
+        return ((Object[])payload)[0];
+    }
+
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        try {
+            Object resp = invokeTarget(msg.getBody(), NONE);
+            msg.setBody(resp);
+        } catch (InvocationTargetException e) {
+            msg.setBodyWithFault(e.getCause());
+        } catch (Throwable e) {
+            msg.setBodyWithFault(e);
+        }
+        return msg;
+    }  
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.tuscany.spi.wire.TargetInvoker#invokeTarget(java.lang.Object, short, org.apache.tuscany.spi.component.WorkContext)
+     */
+    public Object invokeTarget(Object payload, short sequence, WorkContext workContext) throws InvocationTargetException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoModuleActivator.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoModuleActivator.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoModuleActivator.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package echo;
+
+import java.util.Map;
+
+import org.apache.tuscany.services.spi.contribution.StAXArtifactProcessorRegistry;
+import org.apache.tuscany.spi.bootstrap.ExtensionPointRegistry;
+import org.apache.tuscany.spi.bootstrap.ModuleActivator;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+
+
+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
+        return null;
+    }
+
+    public void start(ExtensionPointRegistry registry) {
+
+        // Add the EchoProcessor to the proper registry
+        StAXArtifactProcessorRegistry artifactProcessorRegistry = registry.getExtensionPoint(StAXArtifactProcessorRegistry.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);
+        
+        // Start the Echo server
+        EchoServer.start();
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+        // Remove the EchoProcessor from the proper registry
+        StAXArtifactProcessorRegistry artifactProcessorRegistry = registry.getExtensionPoint(StAXArtifactProcessorRegistry.class);
+        artifactProcessorRegistry.removeArtifactProcessor(echoBindingProcessor);
+
+        EchoServer.stop();
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoReference.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoReference.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoReference.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,55 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.extension.ReferenceBindingExtension;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoReference extends ReferenceBindingExtension {
+
+    protected EchoReference(URI name, URI targetUri) {
+        super(name, targetUri);
+    }
+
+    public QName getBindingType() {
+        return EchoConstants.BINDING_ECHO;
+    }
+
+    
+    public TargetInvoker createTargetInvoker(String name, Operation operation, boolean isCallback)
+       throws TargetInvokerCreationException {
+    if (isCallback) {
+        throw new UnsupportedOperationException();
+    } else {
+        return new EchoInvoker();
+    }
+}
+
+    
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoServer.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoServer.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoServer.java Fri Apr 13 12:43:01 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.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * EchoTransport
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoServer {
+    
+    public static EchoServer server;
+    
+    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
+     */
+    public void register(EchoService service, URI name) {
+        services.put(name, service);
+    }
+
+    /**
+     * Dispatch an incoming interaction to the corresponding service.
+     * @param uri
+     * @param input
+     * @return
+     */
+    public String sendReceive(String composite, String service, String input) {
+        URI uri = URI.create("/" + composite + "/#" + service);
+        return services.get(uri).sendReceive(input);
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoService.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoService.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/java/echo/EchoService.java Fri Apr 13 12:43:01 2007
@@ -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 echo;
+
+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.TargetInvokerCreationException;
+import org.apache.tuscany.spi.extension.ServiceBindingExtension;
+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 QName getBindingType() {
+        return EchoConstants.BINDING_ECHO;
+    }
+
+    public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean isCallback) throws TargetInvokerCreationException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    String sendReceive(String input) {
+        return input;
+    }
+    
+}

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

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

Modified: incubator/tuscany/java/sca/samples/echo-binding/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator?view=diff&rev=528626&r1=528625&r2=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator (original)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator Fri Apr 13 12:43:01 2007
@@ -1,2 +1,2 @@
 # Implementation class for the ExtensionActivator
-org.apache.tuscany.binding.echo.EchoModuleActivator
+echo.EchoModuleActivator

Added: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Echo {
+    String invoke(String msg);
+}

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/Echo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,42 @@
+/*
+ * 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 org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoComponentImpl implements Echo {
+
+    private Echo echoReference;
+
+    @Constructor
+    public EchoComponentImpl(@Reference(name = "echoReference", required = true) Echo echoReference) {
+        this.echoReference = echoReference;
+    }
+
+    public String invoke(String msg) {
+        String result = echoReference.invoke(msg);
+        System.out.println("Returned message: "+ result);
+        return result;
+    }
+}

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java Fri Apr 13 12:43:01 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoReferenceTestCase extends TestCase {
+
+    private Echo service;
+
+    protected void setUp() throws Exception {
+        SCARuntime.start("EchoBinding.composite");
+        ComponentContext context = SCARuntime.getComponentContext("EchoComponent");
+        ServiceReference<Echo> serviceReference = context.createSelfReference(Echo.class);
+        service = serviceReference.getService();
+    }
+    
+    protected void tearDown() throws Exception {
+    	SCARuntime.stop();
+    }
+
+    public void testEchoBinding() {
+        String result = service.invoke("foo");
+        assertEquals(result, "foo");
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoReferenceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java?view=auto&rev=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java Fri Apr 13 12:43:01 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 echo;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoServiceTestCase extends TestCase {
+
+    protected void setUp() throws Exception {
+        SCARuntime.start("EchoBinding.composite");
+    }
+    
+    protected void tearDown() throws Exception {
+    	SCARuntime.stop();
+    }
+
+    public void testEchoBinding() {
+        String result = EchoServer.getServer().sendReceive("EchoBinding", "EchoService", "foo");
+        assertEquals(result, "foo");
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/echo-binding/src/test/java/echo/EchoServiceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/samples/echo-binding/src/test/resources/EchoBinding.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/echo-binding/src/test/resources/EchoBinding.composite?view=diff&rev=528626&r1=528625&r2=528626
==============================================================================
--- incubator/tuscany/java/sca/samples/echo-binding/src/test/resources/EchoBinding.composite (original)
+++ incubator/tuscany/java/sca/samples/echo-binding/src/test/resources/EchoBinding.composite Fri Apr 13 12:43:01 2007
@@ -22,18 +22,18 @@
 	xmlns:echo="http://echo"
 	name="EchoBinding">
 
-    <service name="ClientService" promote="Client">
-        <interface.java interface="org.apache.tuscany.binding.echo.Client"/>
-        <binding.echo uri="echo://tmp" />
+    <service name="EchoService" promote="EchoComponent">
+        <interface.java interface="echo.Echo"/>
+        <binding.echo uri="http://tempuri.org" />
     </service>
 
-    <component name="Client">
-        <implementation.java class="org.apache.tuscany.binding.echo.ClientImpl"/>
+    <component name="EchoComponent">
+        <implementation.java class="echo.EchoComponentImpl"/>
     </component>
     
-    <reference name="EchoReference" promote="Client/echoReference">
-        <interface.java interface="org.apache.tuscany.binding.echo.Echo"/>
-        <binding.echo uri="echo://tmp" />
+    <reference name="EchoReference" promote="EchoComponent/echoReference">
+        <interface.java interface="echo.Echo"/>
+        <binding.echo uri="http://tempuri.org" />
     </reference>
     
 </composite>



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