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/05/08 08:19:21 UTC
svn commit: r536086 - in
/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo: ./
impl/ module/ provider/ server/
Author: jsdelfino
Date: Mon May 7 23:19:20 2007
New Revision: 536086
URL: http://svn.apache.org/viewvc?view=rev&rev=536086
Log:
Separating model implementations from runtime implementation providers.
Added:
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java (with props)
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java Mon May 7 23:19:20 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 echo;
+
+import echo.provider.EchoBindingProviderFactory;
+
+/**
+ * A factory for the sample Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultEchoBindingFactory implements EchoBindingFactory {
+
+ public EchoBinding createEchoBinding() {
+ return new EchoBindingProviderFactory();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java Mon May 7 23:19:20 2007
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * A model for the sample Echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EchoBinding extends Binding {
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java Mon May 7 23:19:20 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 echo;
+
+/**
+ * A factory for the sample Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EchoBindingFactory {
+
+ /**
+ * Creates a new Echo binding.
+ *
+ * @return a new Echi binding
+ */
+ EchoBinding createEchoBinding();
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java Mon May 7 23:19:20 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.policy.Intent;
+import org.apache.tuscany.policy.PolicySet;
+
+import echo.EchoBinding;
+
+/**
+ * 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
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java Mon May 7 23:19:20 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.impl;
+
+import static org.osoa.sca.Constants.SCA_NS;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.contribution.resolver.ModelResolver;
+import org.apache.tuscany.contribution.service.ContributionReadException;
+import org.apache.tuscany.contribution.service.ContributionResolveException;
+import org.apache.tuscany.contribution.service.ContributionWriteException;
+
+import echo.EchoBinding;
+import echo.EchoBindingFactory;
+
+/**
+ * A processor for <binding.echo> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingProcessor implements StAXArtifactProcessor<EchoBinding> {
+
+ private QName BINDING_ECHO = new QName(SCA_NS, "binding.echo");
+
+ private final EchoBindingFactory factory;
+
+ public EchoBindingProcessor(EchoBindingFactory factory) {
+ this.factory = factory;
+ }
+
+ public QName getArtifactType() {
+ return 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 {
+ }
+
+ public void resolve(EchoBinding echoBinding, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java Mon May 7 23:19:20 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.module;
+
+import java.util.Map;
+
+import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.core.ExtensionPointRegistry;
+import org.apache.tuscany.core.ModuleActivator;
+
+import echo.DefaultEchoBindingFactory;
+import echo.EchoBindingFactory;
+import echo.impl.EchoBindingProcessor;
+import echo.server.EchoServer;
+
+/**
+ * A module activator for the sample Echo binding extension.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoModuleActivator implements ModuleActivator {
+
+ private EchoBindingProcessor echoBindingProcessor;
+
+ public Map<Class, Object> getExtensionPoints() {
+ // No extensionPoints being contributed here
+ return null;
+ }
+
+ public void start(ExtensionPointRegistry registry) {
+
+ // Create the Echo model factory
+ EchoBindingFactory echoFactory = new DefaultEchoBindingFactory();
+
+ // Add the EchoProcessor extension
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ echoBindingProcessor = new EchoBindingProcessor(echoFactory);
+ processors.addArtifactProcessor(echoBindingProcessor);
+
+ // Start the Echo server
+ EchoServer.start();
+ }
+
+ public void stop(ExtensionPointRegistry registry) {
+
+ // Remove the EchoProcessor from the registry
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processors.removeArtifactProcessor(echoBindingProcessor);
+
+ EchoServer.stop();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java Mon May 7 23:19:20 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 echo.provider;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+
+/**
+ * Interceptor for the sample echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingInvoker implements Invoker {
+
+ 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) {
+ try {
+ Object resp = echo((Object[])msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java Mon May 7 23:19:20 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.provider;
+
+import org.apache.tuscany.provider.BindingProviderFactory;
+import org.apache.tuscany.provider.ReferenceBindingProvider;
+import org.apache.tuscany.provider.ServiceBindingProvider;
+
+import echo.impl.EchoBindingImpl;
+
+
+/**
+ * Implementation of the Echo binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingProviderFactory extends EchoBindingImpl implements BindingProviderFactory {
+
+ public ReferenceBindingProvider createReferenceBindingProvider() {
+ return new EchoReferenceBindingProvider();
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider() {
+ return new EchoServiceBindingProvider(this);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java Mon May 7 23:19:20 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.provider;
+
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentReference;
+import org.apache.tuscany.core.RuntimeComponentService;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.provider.ReferenceBindingProvider;
+
+
+/**
+ * Implementation of the Echo binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoReferenceBindingProvider implements ReferenceBindingProvider {
+
+ public Invoker createInvoker(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Operation operation,
+ boolean isCallback) {
+ if (isCallback) {
+ throw new UnsupportedOperationException();
+ } else {
+ return new EchoBindingInvoker();
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract(RuntimeComponentReference reference) {
+ return reference.getInterfaceContract();
+ }
+
+ public void start(RuntimeComponent component, RuntimeComponentReference reference) {
+ }
+
+ public void stop(RuntimeComponent component, RuntimeComponentReference reference) {
+ }
+
+ public InterfaceContract getBindingInterfaceContract(RuntimeComponentService service) {
+ return service.getInterfaceContract();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java Mon May 7 23:19:20 2007
@@ -0,0 +1,68 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentService;
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.provider.ServiceBindingProvider;
+
+import echo.EchoBinding;
+import echo.server.EchoServer;
+import echo.server.EchoService;
+
+/**
+ * Implementation of the Echo binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoServiceBindingProvider implements ServiceBindingProvider {
+
+ private EchoBinding binding;
+
+ public EchoServiceBindingProvider(EchoBinding binding) {
+ this.binding = binding;
+ }
+
+ public InterfaceContract getBindingInterfaceContract(RuntimeComponentService service) {
+ return service.getInterfaceContract();
+ }
+
+ public void start(RuntimeComponent component, RuntimeComponentService service) {
+
+ RuntimeComponentService componentService = (RuntimeComponentService) service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+ InvocationChain chain = wire.getInvocationChains().get(0);
+
+ // Register with the hosting server
+ String uri = component.getURI() + "/" + binding.getName();
+ EchoServer.getServer().register(uri, new EchoService(chain.getHeadInvoker()));
+ }
+
+ public void stop(RuntimeComponent component, RuntimeComponentService service) {
+
+ // Unregister from the hosting server
+ String uri = component.getURI() + "/" + binding.getName();
+ EchoServer.getServer().unregister(uri);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java Mon May 7 23:19:20 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package echo.server;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A sample Echo server, showing how to integrate service bindings.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoServer {
+
+ public static EchoServer server;
+
+ private Map<String, EchoService> services = new HashMap<String, 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(String uri, EchoService service) {
+ services.put(uri, service);
+ }
+
+ public void unregister(String uri) {
+ services.remove(uri);
+ }
+
+ /**
+ * Dispatch an incoming interaction to the corresponding service.
+ *
+ * @param uri
+ * @param input
+ * @return
+ */
+ public String sendReceive(String uri, String input) throws InvocationTargetException {
+ return services.get(uri).sendReceive(input);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoServer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java?view=auto&rev=536086
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java Mon May 7 23:19:20 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.server;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+import org.apache.tuscany.invocation.MessageImpl;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.WorkContextTunnel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoService {
+ private Invoker invoker;
+
+ public EchoService(Invoker invoker) {
+ super();
+ this.invoker = invoker;
+ }
+
+ public String sendReceive(String input) throws InvocationTargetException {
+
+ WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
+
+ Message msg = new MessageImpl();
+ msg.setBody(new Object[] {input});
+ msg.setWorkContext(workContext);
+ Message resp;
+
+ // dispatch and get the response
+ resp = invoker.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return (String)body;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/server/EchoService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org