From 9191d70401329c8dab8d763a8fcbc3e7f08c8628 Mon Sep 17 00:00:00 2001 From: fmoga Date: Wed, 6 Jul 2011 13:45:43 +0000 Subject: Add scaffolded websocket binding code using Monsoon from filesystem Maven repo. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1143410 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/binding-websocket/META-INF/MANIFEST.MF | 17 ++++++ .../0.0.1-SNAPSHOT/maven-metadata-local.xml | 12 ++++ .../0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.jar | Bin 0 -> 40319 bytes .../0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.pom | 9 +++ .../org/apache/websocket/maven-metadata-local.xml | 12 ++++ .../contrib/modules/binding-websocket/pom.xml | 67 +++++++++++++++++++++ .../sca/binding/websocket/WebsocketBinding.java | 40 ++++++++++++ .../binding/websocket/WebsocketBindingFactory.java | 31 ++++++++++ .../runtime/WebsocketBindingProviderFactory.java | 47 +++++++++++++++ .../runtime/WebsocketReferenceBindingProvider.java | 55 +++++++++++++++++ .../runtime/WebsocketReferenceInvoker.java | 51 ++++++++++++++++ .../runtime/WebsocketServiceBindingProvider.java | 51 ++++++++++++++++ .../websocket/runtime/WebsocketServiceInvoker.java | 40 ++++++++++++ .../binding/websocket/runtime/WebsocketStash.java | 44 ++++++++++++++ ...y.sca.binding.websocket.WebsocketBindingFactory | 20 ++++++ ...ca.contribution.processor.StAXArtifactProcessor | 20 ++++++ ...any.sca.contribution.processor.ValidationSchema | 19 ++++++ ...che.tuscany.sca.provider.BindingProviderFactory | 20 ++++++ .../src/main/resources/binding-websocket.xsd | 37 ++++++++++++ .../src/test/java/helloworld/HelloWorldClient.java | 33 ++++++++++ .../src/test/java/helloworld/HelloWorldImpl.java | 28 +++++++++ .../test/java/helloworld/HelloWorldService.java | 28 +++++++++ .../test/java/test/WebsocketBindingTestCase.java | 52 ++++++++++++++++ .../src/test/resources/helloworld.composite | 39 ++++++++++++ 24 files changed, 772 insertions(+) create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/META-INF/MANIFEST.MF create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/maven-metadata-local.xml create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.jar create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.pom create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/maven-metadata-local.xml create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/pom.xml create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBinding.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBindingFactory.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceBindingProvider.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceInvoker.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStash.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/binding-websocket.xsd create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java create mode 100644 sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite (limited to 'sca-java-2.x/contrib') diff --git a/sca-java-2.x/contrib/modules/binding-websocket/META-INF/MANIFEST.MF b/sca-java-2.x/contrib/modules/binding-websocket/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2f29092dbe --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +SCA-Version: 1.1 +Bundle-Name: Apache Tuscany SCA Websocket Binding +Bundle-Vendor: The Apache Software Foundation +Bundle-Version: 2.0.0 +Bundle-ManifestVersion: 2 +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Bundle-Description: Apache Tuscany SCA Websocket Binding +Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0", + org.apache.tuscany.sca.core;version="2.0.0", + org.apache.tuscany.sca.interfacedef;version="2.0.0", + org.apache.tuscany.sca.invocation;version="2.0.0", + org.apache.tuscany.sca.provider;version="2.0.0", + org.apache.tuscany.sca.runtime;version="2.0.0" +Bundle-SymbolicName: org.apache.tuscany.sca.binding.binding-websocket +Bundle-DocURL: http://www.apache.org/ +Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/maven-metadata-local.xml b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000000..8992bb6877 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + org.apache + websocket + 0.0.1-SNAPSHOT + + + true + + 20110706132527 + + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.jar b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.jar new file mode 100644 index 0000000000..9752b0a69f Binary files /dev/null and b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.jar differ diff --git a/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.pom b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.pom new file mode 100644 index 0000000000..118bbdb13e --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/0.0.1-SNAPSHOT/websocket-0.0.1-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + org.apache + websocket + 0.0.1-SNAPSHOT + POM was created from install:install-file + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/maven-metadata-local.xml b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/maven-metadata-local.xml new file mode 100644 index 0000000000..edaaf8e7e9 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/monsoon-repo/org/apache/websocket/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + org.apache + websocket + 0.0.1-SNAPSHOT + + + 0.0.1-SNAPSHOT + + 20110706132527 + + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/pom.xml b/sca-java-2.x/contrib/modules/binding-websocket/pom.xml new file mode 100644 index 0000000000..2ce7fda832 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-SNAPSHOT + ../pom.xml + + + org.apache.tuscany.sca + tuscany-binding-websocket + 2.0-SNAPSHOT + Apache Tuscany SCA Websocket Binding Extension + + + + + org.apache.tuscany.sca + tuscany-base-runtime-pom + pom + 2.0-SNAPSHOT + provided + + + + org.apache + websocket + 0.0.1-SNAPSHOT + compile + + + + junit + junit + 4.8.1 + test + + + + + + + monsoon-local + file://${basedir}/monsoon-repo + + + + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBinding.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBinding.java new file mode 100644 index 0000000000..8988b376de --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBinding.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.websocket; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.provider.BaseBindingImpl; + +/** + * Represents a binding to a Websocket service. + */ +public class WebsocketBinding extends BaseBindingImpl { + + public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.websocket"); + + public WebsocketBinding() { + } + + @Override + public QName getType() { + return TYPE; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBindingFactory.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBindingFactory.java new file mode 100644 index 0000000000..52147b1fdb --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBindingFactory.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.websocket; + +/** + * Factory implementation to create Websocket Models + */ +public class WebsocketBindingFactory { + + public WebsocketBinding createWebsocketBinding() { + return new WebsocketBinding(); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java new file mode 100644 index 0000000000..d7f8ef98a5 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.websocket.runtime; + +import org.apache.tuscany.sca.binding.websocket.WebsocketBinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +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.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; + +public class WebsocketBindingProviderFactory implements BindingProviderFactory { + + public WebsocketBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public Class getModelType() { + return WebsocketBinding.class; + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) { + return new WebsocketReferenceBindingProvider(endpoint); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { + return new WebsocketServiceBindingProvider(endpoint); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceBindingProvider.java new file mode 100644 index 0000000000..2766c3d991 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceBindingProvider.java @@ -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 org.apache.tuscany.sca.binding.websocket.runtime; + +import org.apache.tuscany.sca.assembly.EndpointReference; +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; + +public class WebsocketReferenceBindingProvider implements ReferenceBindingProvider { + + private EndpointReference endpoint; + private InterfaceContract contract; + + public WebsocketReferenceBindingProvider(EndpointReference endpoint) { + this.endpoint = endpoint; + } + + public Invoker createInvoker(Operation operation) { + return new WebsocketReferenceInvoker(operation, endpoint); + } + + public void start() { + } + + public void stop() { + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceInvoker.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceInvoker.java new file mode 100644 index 0000000000..a87c87dfb2 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceInvoker.java @@ -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 org.apache.tuscany.sca.binding.websocket.runtime; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +public class WebsocketReferenceInvoker implements Invoker { + + protected Operation operation; + protected EndpointReference endpoint; + + public WebsocketReferenceInvoker(Operation operation, EndpointReference endpoint) { + this.operation = operation; + this.endpoint = endpoint; + } + + public Message invoke(Message msg) { + try { + + return doInvoke(msg); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public Message doInvoke(Message msg) { + WebsocketServiceInvoker fi = WebsocketStash.getService(endpoint.getBinding().getURI()); + return fi.invokeService(msg); + } +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java new file mode 100644 index 0000000000..f5ed85a30a --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java @@ -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 org.apache.tuscany.sca.binding.websocket.runtime; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +public class WebsocketServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeEndpoint endpoint; + private InterfaceContract contract; + + public WebsocketServiceBindingProvider(RuntimeEndpoint endpoint) { + this.endpoint = endpoint; + } + + public void start() { + WebsocketStash.addService(endpoint.getBinding().getURI(), new WebsocketServiceInvoker(endpoint)); + } + + public void stop() { + WebsocketStash.removeService(endpoint.getBinding().getURI()); + } + + public InterfaceContract getBindingInterfaceContract() { + return contract; + } + + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java new file mode 100644 index 0000000000..410312a538 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.websocket.runtime; + +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +public class WebsocketServiceInvoker { + + private RuntimeEndpoint wire; + + public WebsocketServiceInvoker(RuntimeEndpoint wire) { + this.wire = wire; + } + + /** + * Send the request down the wire to invoke the service + */ + public Message invokeService(Message msg) { + return wire.invoke(msg); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStash.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStash.java new file mode 100644 index 0000000000..0023cf915d --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStash.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.websocket.runtime; + +import java.util.HashMap; +import java.util.Map; + +/** + * Simplistic static Map to share service endpoints with references + */ +public class WebsocketStash { + + private static Map services = new HashMap(); + + public static void addService(String uri, WebsocketServiceInvoker WebsocketServiceInvoker) { + services.put(uri, WebsocketServiceInvoker); + } + + public static WebsocketServiceInvoker getService(String uri) { + return services.get(uri); + } + + public static void removeService(String uri) { + services.remove(uri); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory new file mode 100644 index 0000000000..4ec8ba4eb2 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..fd2e21a468 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.websocket,model=org.apache.tuscany.sca.binding.websocket.WebsocketBinding,factory=org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..d4a7646f48 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# 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. +# +binding-websocket.xsd + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..e97707636d --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,20 @@ +# 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. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.websocket.runtime.WebsocketBindingProviderFactory;model=org.apache.tuscany.sca.binding.websocket.WebsocketBinding + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/binding-websocket.xsd b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/binding-websocket.xsd new file mode 100644 index 0000000000..daccffc814 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/binding-websocket.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..136c9baba8 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldClient.java @@ -0,0 +1,33 @@ +/* + * 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 helloworld; + +import org.oasisopen.sca.annotation.Reference; + +public class HelloWorldClient implements HelloWorldService { + + @Reference + public HelloWorldService ref; + + public String sayHello(String name) { + return ref.sayHello(name); + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c307547f56 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldImpl.java @@ -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 helloworld; + + +public class HelloWorldImpl implements HelloWorldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..064d615c45 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/helloworld/HelloWorldService.java @@ -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 helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HelloWorldService { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java new file mode 100644 index 0000000000..cd8f20c11e --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/test/WebsocketBindingTestCase.java @@ -0,0 +1,52 @@ +/* + * 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 test; + +import helloworld.HelloWorldService; +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class WebsocketBindingTestCase { + + private static Node node; + + @Test + public void testSayHello() { + HelloWorldService service = node.getService(HelloWorldService.class, "HelloWorldClient/HelloWorldService"); + Assert.assertEquals("Hello boo", service.sayHello("boo")); + } + + @BeforeClass + public static void init() throws Exception { + node = NodeFactory.newInstance().createNode("helloworld.composite").start(); + } + + @AfterClass + public static void destroy() throws Exception { + if (node != null) { + node.stop(); + } + } + +} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite new file mode 100644 index 0000000000..6ce4f87334 --- /dev/null +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/helloworld.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3