From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/echo/DefaultEchoBindingFactory.java | 33 ---------- .../src/main/java/echo/EchoBinding.java | 28 -------- .../src/main/java/echo/EchoBindingFactory.java | 33 ---------- .../src/main/java/echo/impl/EchoBindingImpl.java | 77 ---------------------- .../main/java/echo/impl/EchoBindingProcessor.java | 73 -------------------- .../main/java/echo/module/EchoModuleActivator.java | 69 ------------------- .../java/echo/provider/EchoBindingInvoker.java | 48 -------------- .../echo/provider/EchoBindingProviderFactory.java | 55 ---------------- .../provider/EchoReferenceBindingProvider.java | 62 ----------------- .../echo/provider/EchoServiceBindingProvider.java | 74 --------------------- .../src/main/java/echo/server/EchoServer.java | 72 -------------------- .../src/main/java/echo/server/EchoService.java | 53 --------------- 12 files changed, 677 deletions(-) delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBinding.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoServer.java delete mode 100644 branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoService.java (limited to 'branches/sca-java-0.90/samples/binding-echo/src/main/java/echo') diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java deleted file mode 100644 index b27b936302..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/DefaultEchoBindingFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.impl.EchoBindingImpl; - -/** - * A factory for the sample Echo binding model. - */ -public class DefaultEchoBindingFactory implements EchoBindingFactory { - - public EchoBinding createEchoBinding() { - return new EchoBindingImpl(); - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBinding.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBinding.java deleted file mode 100644 index 446f720634..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBinding.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.sca.assembly.Binding; - -/** - * A model for the sample Echo binding. - */ -public interface EchoBinding extends Binding { -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java deleted file mode 100644 index d893babb18..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/EchoBindingFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ -public interface EchoBindingFactory { - - /** - * Creates a new Echo binding. - * - * @return a new Echi binding - */ - EchoBinding createEchoBinding(); -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java deleted file mode 100644 index ef1629d519..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -import echo.EchoBinding; - -/** - * Implementation of the Echo binding model. - */ -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 getPolicySets() { - // The sample binding does not support policies - return Collections.emptyList(); - } - - public List getRequiredIntents() { - // The sample binding does not support policies - return Collections.emptyList(); - } - - public List 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 - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java deleted file mode 100644 index aba0b14d55..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/impl/EchoBindingProcessor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; - -import echo.EchoBinding; -import echo.EchoBindingFactory; - -/** - * A processor for elements. - */ -public class EchoBindingProcessor implements StAXArtifactProcessor { - - 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 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 { - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java deleted file mode 100644 index 268b903e54..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/module/EchoModuleActivator.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; - -import echo.DefaultEchoBindingFactory; -import echo.EchoBindingFactory; -import echo.impl.EchoBindingProcessor; -import echo.provider.EchoBindingProviderFactory; -import echo.server.EchoServer; - -/** - * A module activator for the sample Echo binding extension. - */ -public class EchoModuleActivator implements ModuleActivator { - - public Object[] getExtensionPoints() { - // No extensionPoints being contributed here - return null; - } - - public void start(ExtensionPointRegistry registry) { - - ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); - MessageFactory messageFactory = factories.getFactory(MessageFactory.class); - - // Create the Echo model factory - EchoBindingFactory echoFactory = new DefaultEchoBindingFactory(); - - // Add the EchoProcessor extension - StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - EchoBindingProcessor echoBindingProcessor = new EchoBindingProcessor(echoFactory); - processors.addArtifactProcessor(echoBindingProcessor); - - ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - providerFactories.addProviderFactory(new EchoBindingProviderFactory(messageFactory)); - - // Start the Echo server - EchoServer.start(); - } - - public void stop(ExtensionPointRegistry registry) { - EchoServer.stop(); - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java deleted file mode 100644 index e3d52fa703..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingInvoker.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -/** - * Interceptor for the sample echo binding. - */ -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; - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java deleted file mode 100644 index 623cb0e16e..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoBindingProviderFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -import echo.EchoBinding; - - -/** - * Implementation of the Echo binding model. - */ -public class EchoBindingProviderFactory implements BindingProviderFactory { - - private MessageFactory messageFactory; - - public EchoBindingProviderFactory(MessageFactory messageFactory) { - this.messageFactory = messageFactory; - } - - public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, EchoBinding binding) { - return new EchoReferenceBindingProvider(component, reference, binding); - } - - public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, EchoBinding binding) { - return new EchoServiceBindingProvider(component, service, binding, messageFactory); - } - - public Class getModelType() { - return EchoBinding.class; - } -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java deleted file mode 100644 index dd1a8f42f8..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoReferenceBindingProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; - -import echo.EchoBinding; - -/** - * Implementation of the Echo binding provider. - */ -public class EchoReferenceBindingProvider implements ReferenceBindingProvider { - - private RuntimeComponentReference reference; - - public EchoReferenceBindingProvider(RuntimeComponent component, - RuntimeComponentReference reference, - EchoBinding binding) { - this.reference = reference; - } - - public Invoker createInvoker(Operation operation, boolean isCallback) { - if (isCallback) { - throw new UnsupportedOperationException(); - } else { - return new EchoBindingInvoker(); - } - } - - public InterfaceContract getBindingInterfaceContract() { - return reference.getInterfaceContract(); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java deleted file mode 100644 index 896e40df8d..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/provider/EchoServiceBindingProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -import echo.EchoBinding; -import echo.server.EchoServer; -import echo.server.EchoService; - -/** - * Implementation of the Echo binding provider. - */ -public class EchoServiceBindingProvider implements ServiceBindingProvider { - - private RuntimeComponent component; - private RuntimeComponentService service; - private EchoBinding binding; - private MessageFactory messageFactory; - - public EchoServiceBindingProvider(RuntimeComponent component, - RuntimeComponentService service, EchoBinding binding, MessageFactory messageFactory) { - this.component = component; - this.service = service; - this.binding = binding; - this.messageFactory = messageFactory; - } - - public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); - } - - public void start() { - - 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(), messageFactory)); - } - - public void stop() { - - // Unregister from the hosting server - String uri = component.getURI() + "/" + binding.getName(); - EchoServer.getServer().unregister(uri); - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoServer.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoServer.java deleted file mode 100644 index e1c88c38f9..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoServer.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. - */ -public class EchoServer { - - public static EchoServer server; - - private Map services = new HashMap(); - - 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); - } - -} diff --git a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoService.java b/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoService.java deleted file mode 100644 index 79593b2b6c..0000000000 --- a/branches/sca-java-0.90/samples/binding-echo/src/main/java/echo/server/EchoService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.MessageFactory; - -/** - * The EchoService - */ -public class EchoService { - private Invoker invoker; - private MessageFactory messageFactory; - - public EchoService(Invoker invoker, MessageFactory messageFactory) { - super(); - this.invoker = invoker; - this.messageFactory = messageFactory; - } - - public String sendReceive(String input) throws InvocationTargetException { - - Message request = messageFactory.createMessage(); - request.setBody(new Object[] {input}); - // dispatch and get the response - Message response = invoker.invoke(request); - Object body = response.getBody(); - if (response.isFault()) { - throw new InvocationTargetException((Throwable)body); - } - return (String)body; - } - -} -- cgit v1.2.3