diff options
Diffstat (limited to 'sca-java-2.x/contrib/modules/binding-websocket/src')
31 files changed, 0 insertions, 1553 deletions
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/META-INF/MANIFEST.MF b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 5e9495128c..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0
-Class-Path:
-
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 deleted file mode 100644 index a78a6b11c2..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBinding.java +++ /dev/null @@ -1,49 +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 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");
- private String port;
-
- public WebsocketBinding() {
- }
-
- @Override
- public QName getType() {
- return TYPE;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
-}
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 deleted file mode 100644 index 1357bb5a7c..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/WebsocketBindingFactory.java +++ /dev/null @@ -1,31 +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 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/JSONUtil.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java deleted file mode 100644 index 80cbf6a6d9..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java +++ /dev/null @@ -1,106 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.Operation; - -import com.google.gson.Gson; - -/** - * Utility class to handle JSON convertions. - */ -public class JSONUtil { - - private static Gson gson = new Gson(); - - public static String encodeMessage(WebsocketBindingMessage message) { - return gson.toJson(message); - } - - public static WebsocketBindingMessage decodeMessage(String jsonMessage) { - return gson.fromJson(jsonMessage, WebsocketBindingMessage.class); - } - - public static String encodePayload(Object payload) { - return gson.toJson(payload); - } - - /** - * Convert opeartion parameters from JSON to the appropriate parameter - * types. - */ - public static Object[] decodePayloadForOperation(String jsonData, Operation operation) { - Object[] args = new Object[operation.getInputType().getLogical().size()]; - final String[] json = parseArray(jsonData); - int index = 0; - for (final DataType<?> dataType : operation.getInputType().getLogical()) { - args[index] = gson.fromJson(json[index], dataType.getPhysical()); - index++; - } - return args; - } - - /** - * Split the JSON array containing the arguments for the opeartion in order - * to avoid converting JSON to Object[]. Converting each object separately - * to it's corresponding data type avoids type mismatch problems at service - * invocation. - */ - private static String[] parseArray(String jsonArray) { - List<String> objects = new ArrayList<String>(); - int bracketNum = 0; - int parNum = 0; - int quoteNum = 0; - int startPos = 1; - for (int i = 0; i < jsonArray.length(); i++) { - switch (jsonArray.charAt(i)) { - case '{': - bracketNum++; - break; - case '}': - bracketNum--; - break; - case '[': - parNum++; - break; - case ']': - parNum--; - break; - case '\"': - quoteNum++; - break; - case ',': - if ((bracketNum == 0) && (parNum == 1) && quoteNum % 2 == 0) { - objects.add(jsonArray.substring(startPos, i)); - startPos = i + 1; - } - } - } - objects.add(jsonArray.substring(startPos, jsonArray.length() - 1)); - return objects.toArray(new String[] {}); - } - - private JSONUtil() { - } - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptGenerator.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptGenerator.java deleted file mode 100644 index 21b953151b..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptGenerator.java +++ /dev/null @@ -1,113 +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.
- */
-
-/*
- * 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.List;
-
-import org.apache.tuscany.sca.interfacedef.Operation;
-
-/**
- * Generates javascript service proxies using the websocket API. This enables
- * simulating SCA on the client side javascript. This is a stateful singleton.
- */
-public class JavascriptGenerator {
-
- private final static String CONTEXT = "this.WebsocketComponentContext";
- private static final String LF = "\n";
- private static StringBuilder builder = new StringBuilder();
-
- /**
- * Generate javascript code for one service and all it's operations. Add
- * this to the state of the generator.
- */
- public static void generateServiceProxy(String component, String service, List<Operation> operations, int port) {
- if (builder.length() == 0) {
- builder.append(CONTEXT).append("={};").append(LF);
- }
- builder.append("if(!" + CONTEXT + "." + component + ")" + CONTEXT + "." + component + "={};").append(LF);
- builder.append(CONTEXT + "." + component + "." + service + "={};").append(LF);
- for (Operation operation : operations) {
- builder.append(
- CONTEXT + "." + component + "." + service + "." + operation.getName() + "="
- + generateFunctionHeader(operation)).append(LF);
- builder.append(generateFunctionContent(port, component, service, operation)).append(LF);
- builder.append("};").append(LF);
- }
- }
-
- private static String generateFunctionHeader(Operation operation) {
- String header = "function(";
- for (int i = 0; i < operation.getInputType().getLogical().size(); i++) {
- if (i > 0)
- header += ",";
- header += "p" + i;
- }
- header += ") {";
- return header;
- }
-
- private static String generateFunctionContent(int port, String component, String service, Operation operation) {
- String content = "sendMessage(" + port + ",'" + component + "." + service + "." + operation.getName() + "',[";
- for (int i = 0; i < operation.getInputType().getLogical().size(); i++) {
- if (i > 0)
- content += ",";
- content += "p" + i;
- }
- content += "]);";
- return content;
- }
-
- /**
- * Get the state of the generator.
- */
- public static String getServiceProxies() {
- return builder.toString();
- }
-
- /**
- * Reset the state of the generator.
- */
- public static void clear() {
- builder.setLength(0);
- }
-
- private JavascriptGenerator() {
- }
-
-}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptResourceServlet.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptResourceServlet.java deleted file mode 100644 index 50d68a19bc..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JavascriptResourceServlet.java +++ /dev/null @@ -1,105 +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.
- */
-
-/*
- * 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.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * This servlet serves the generated javascript service proxies.
- */
-public class JavascriptResourceServlet extends HttpServlet {
-
- private static final String WEBSOCKET_TOOLKIT_PATH = "js/TuscanyWebsocketToolkit.js";
-
- private String websocketToolkit;
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
- try {
- resp.setContentType("text/javascript");
- OutputStream os = resp.getOutputStream();
- os.write("var Tuscany = new function() {\n".getBytes());
- os.write(getWebsocketToolkit().getBytes());
- os.write(JavascriptGenerator.getServiceProxies().getBytes());
- os.write("}\n".getBytes());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private String getWebsocketToolkit() {
- if (websocketToolkit == null) {
- websocketToolkit = getResource(WEBSOCKET_TOOLKIT_PATH);
- }
- return websocketToolkit;
- }
-
- /**
- * Read a resource from the disk by relative path.
- */
- private String getResource(String path) {
- InputStream is = getClass().getClassLoader().getResourceAsStream(path);
- BufferedReader r = new BufferedReader(new InputStreamReader(is));
- StringBuilder builder = new StringBuilder();
- try {
- String line = null;
- while ((line = r.readLine()) != null) {
- builder.append(line + "\n");
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- try {
- r.close();
- } catch (IOException ignored) {
- }
- }
- return builder.toString();
- }
-
-}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/TuscanyWebsocket.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/TuscanyWebsocket.java deleted file mode 100644 index b71ca27543..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/TuscanyWebsocket.java +++ /dev/null @@ -1,85 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -import java.io.IOException; -import java.util.UUID; - -import org.eclipse.jetty.websocket.WebSocket; - -/** - * A websocket connection handling communication between one browser client and - * *all* websocket services hosted by a server. The connection is persisted as - * long as the client is connected and communication with all services is - * multiplexed via a single websocket connection. - */ -public class TuscanyWebsocket implements WebSocket, WebSocket.OnTextMessage { - - private String id; - private Connection connection; - private WebsocketBindingDispatcher dispatcher; - - public TuscanyWebsocket(WebsocketBindingDispatcher dispatcher) { - this.dispatcher = dispatcher; - } - - @Override - public void onOpen(Connection connection) { - this.connection = connection; - this.id = UUID.randomUUID().toString(); - WebsocketConnectionManager.addConnection(this); - } - - @Override - public void onMessage(String jsonRequest) { - WebsocketBindingMessage request = JSONUtil.decodeMessage(jsonRequest); - WebsocketServiceInvoker invoker = dispatcher.dispatch(request.getOperation()); - if (invoker == null) { - throw new RuntimeException("No operation found for " + request.getOperation()); - } else { - if (!invoker.isNonBlocking()) { - WebsocketBindingMessage response = invoker.invokeSync(request); - send(response); - } else { - invoker.invokeAsync(request, this); - } - } - } - - @Override - public void onClose(int closeCode, String message) { - WebsocketConnectionManager.removeConnection(this); - } - - public void send(WebsocketBindingMessage message) { - try { - if (connection.isOpen()) { - connection.sendMessage(JSONUtil.encodeMessage(message)); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public String getId() { - return id; - } - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingCallback.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingCallback.java deleted file mode 100644 index 3ece55aa00..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingCallback.java +++ /dev/null @@ -1,31 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * Interface describing the websocket binding callback to a browser client. - */ -@Remotable -public interface WebsocketBindingCallback { - - public WebsocketStatus sendMessage(Object message); - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java deleted file mode 100644 index eda78de98a..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingDispatcher.java +++ /dev/null @@ -1,42 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.runtime.RuntimeEndpoint; - -/** - * A dispatcher stores all service invokers for a servers and is used to - * determine which one of them should be used when a request comes in. - */ -public class WebsocketBindingDispatcher { - - private Map<String, WebsocketServiceInvoker> invokers = new HashMap<String, WebsocketServiceInvoker>(); - - public void addOperation(String uri, RuntimeEndpoint endpoint, Operation operation) { - invokers.put(uri, new WebsocketServiceInvoker(operation, endpoint)); - } - - public WebsocketServiceInvoker dispatch(String uri) { - return invokers.get(uri); - } -}
\ No newline at end of file diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingMessage.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingMessage.java deleted file mode 100644 index f7ea1d1620..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingMessage.java +++ /dev/null @@ -1,50 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -/** - * The websocket binding message structure. - */ -public class WebsocketBindingMessage { - - private String operation; - private String payload; - - public WebsocketBindingMessage(String operation, String payload) { - this.operation = operation; - this.payload = payload; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - -} 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 deleted file mode 100644 index 5c5f96bd76..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketBindingProviderFactory.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 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.host.http.ServletHost;
-import org.apache.tuscany.sca.host.http.ServletHostHelper;
-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;
-
-/**
- * Factory for reference and service binding providers.
- */
-public class WebsocketBindingProviderFactory implements BindingProviderFactory<WebsocketBinding> {
-
- private ServletHost servletHost;
-
- public WebsocketBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
- this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
- }
-
- public Class<WebsocketBinding> getModelType() {
- return WebsocketBinding.class;
- }
-
- public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) {
- return new WebsocketReferenceBindingProvider(endpoint);
- }
-
- public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
- return new WebsocketServiceBindingProvider(endpoint, servletHost);
- }
-
-}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketCallbackInvoker.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketCallbackInvoker.java deleted file mode 100644 index ebd7f13081..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketCallbackInvoker.java +++ /dev/null @@ -1,59 +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 org.apache.tuscany.sca.binding.websocket.runtime;
-
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.invocation.Constants;
-import org.apache.tuscany.sca.core.invocation.impl.MessageImpl;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-
-/**
- * The callback invoker is used to send asynchronous responses back to the
- * browser client.
- */
-public class WebsocketCallbackInvoker implements Invoker {
-
- protected Operation operation;
- protected EndpointReference endpoint;
-
- public WebsocketCallbackInvoker(Operation operation, EndpointReference endpoint) {
- this.operation = operation;
- this.endpoint = endpoint;
- }
-
- public Message invoke(Message msg) {
- String channelId = (String) msg.getHeaders().get(Constants.RELATES_TO);
- TuscanyWebsocket websocket = WebsocketConnectionManager.getConnection(channelId);
- Message response = new MessageImpl();
- if (websocket == null) {
- response.setBody(WebsocketStatus.CLOSED);
- } else {
- Object[] body = msg.getBody();
- String payload = JSONUtil.encodePayload(body[0]);
- String operation = msg.getTo().getURI();
- WebsocketBindingMessage message = new WebsocketBindingMessage(operation, payload);
- websocket.send(message);
- response.setBody(WebsocketStatus.OPEN);
- }
- return response;
- }
-}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketConnectionManager.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketConnectionManager.java deleted file mode 100644 index ba95d77b7f..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketConnectionManager.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 org.apache.tuscany.sca.binding.websocket.runtime; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * The connection manager stores all active websocket connections in order to be - * able to retrieve the appropriate communication channel when an asynchronous - * response is sent. - */ -public class WebsocketConnectionManager { - - private static ConcurrentMap<String, TuscanyWebsocket> activeConnections = new ConcurrentHashMap<String, TuscanyWebsocket>(); - - public static void addConnection(TuscanyWebsocket websocket) { - activeConnections.put(websocket.getId(), websocket); - } - - public static void removeConnection(TuscanyWebsocket websocket) { - activeConnections.remove(websocket.getId()); - } - - public static TuscanyWebsocket getConnection(String id) { - return activeConnections.get(id); - } - - public static void clear() { - activeConnections.clear(); - } - - private WebsocketConnectionManager() { - } - -} 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 deleted file mode 100644 index dfd632d330..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketReferenceBindingProvider.java +++ /dev/null @@ -1,60 +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 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;
-
-/**
- * The reference binding provider is used to initiate the necessary
- * infrastructure on the reference side. As the binding only supports browser
- * clients, the reference binding provider is used as a factory for callback
- * invokers.
- */
-public class WebsocketReferenceBindingProvider implements ReferenceBindingProvider {
-
- private EndpointReference endpoint;
-
- public WebsocketReferenceBindingProvider(EndpointReference endpoint) {
- this.endpoint = endpoint;
- }
-
- public Invoker createInvoker(Operation operation) {
- return new WebsocketCallbackInvoker(operation, endpoint);
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return endpoint.getComponentReferenceInterfaceContract();
- }
-
- 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/WebsocketServer.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServer.java deleted file mode 100644 index cde86b0575..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServer.java +++ /dev/null @@ -1,59 +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 org.apache.tuscany.sca.binding.websocket.runtime; - -import java.net.URISyntaxException; - -import javax.servlet.http.HttpServletRequest; - -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.nio.SelectChannelConnector; -import org.eclipse.jetty.websocket.WebSocket; -import org.eclipse.jetty.websocket.WebSocketHandler; - -/** - * The websocket server is an embedded Jetty instance which will be started on - * the port specified in the component definition. - */ -public class WebsocketServer extends Server { - - private WebsocketBindingDispatcher dispatcher; - - public WebsocketServer(int port) throws URISyntaxException { - SelectChannelConnector connector = new SelectChannelConnector(); - connector.setPort(port); - addConnector(connector); - - setHandler(new WebSocketHandler() { - - @Override - public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { - return new TuscanyWebsocket(dispatcher); - } - }); - - dispatcher = new WebsocketBindingDispatcher(); - } - - public WebsocketBindingDispatcher getDispatcher() { - return dispatcher; - } - -} 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 deleted file mode 100644 index 2352970b2e..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java +++ /dev/null @@ -1,109 +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 org.apache.tuscany.sca.binding.websocket.runtime;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.binding.websocket.WebsocketBinding;
-import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-/**
- * The service binding provider initiates the necessary infrastructure to expose
- * services via websockets.
- */
-public class WebsocketServiceBindingProvider implements ServiceBindingProvider {
-
- private static final int DEFAULT_PORT = 9000;
- private static final String JAVASCRIPT_RESOURCE_PATH = "/org.apache.tuscany.sca.WebsocketComponentContext.js";
- private static Map<Integer, WebsocketServer> servers = new HashMap<Integer, WebsocketServer>();
- private RuntimeEndpoint endpoint;
- private ServletHost servletHost;
-
- public WebsocketServiceBindingProvider(RuntimeEndpoint endpoint, ServletHost servletHost) {
- this.endpoint = endpoint;
- this.servletHost = servletHost;
- }
-
- public void start() {
- WebsocketBinding binding = (WebsocketBinding) endpoint.getBinding();
- int port = DEFAULT_PORT;
- if (binding.getPort() != null) {
- port = Integer.parseInt(binding.getPort());
- }
- try {
- WebsocketServer server = initServerForURI(port);
- String component = endpoint.getComponent().getName();
- String service = endpoint.getService().getName();
- for (Operation op : getBindingInterfaceContract().getInterface().getOperations()) {
- String operation = op.getName();
- server.getDispatcher().addOperation(component + "." + service + "." + operation, endpoint, op);
- }
- JavascriptGenerator.generateServiceProxy(component, service, getBindingInterfaceContract().getInterface()
- .getOperations(), port);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- initJavascriptResource();
- }
-
- private WebsocketServer initServerForURI(int port) throws Exception {
- WebsocketServer server = servers.get(port);
- if (server == null) {
- server = new WebsocketServer(port);
- server.start();
- servers.put(port, server);
- }
- return server;
- }
-
- private void initJavascriptResource() {
- if (servletHost.getServletMapping(JAVASCRIPT_RESOURCE_PATH) == null) {
- servletHost.addServletMapping(JAVASCRIPT_RESOURCE_PATH, new JavascriptResourceServlet());
- }
- }
-
- public void stop() {
- for (WebsocketServer server : servers.values()) {
- try {
- server.stop();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- servers.clear();
- servletHost.removeServletMapping(JAVASCRIPT_RESOURCE_PATH);
- JavascriptGenerator.clear();
- WebsocketConnectionManager.clear();
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return endpoint.getService().getInterfaceContract();
- }
-
- 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 deleted file mode 100644 index 6c7a25c59e..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceInvoker.java +++ /dev/null @@ -1,97 +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.
- */
-
-/*
- * 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.lang.reflect.InvocationTargetException;
-
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
-import org.apache.tuscany.sca.core.invocation.Constants;
-import org.apache.tuscany.sca.core.invocation.impl.MessageImpl;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-
-/**
- * The service invoker is used to call an operation implementation in a
- * synchronous or asynchronous way.
- */
-public class WebsocketServiceInvoker {
-
- protected Operation operation;
- protected RuntimeEndpoint endpoint;
-
- public WebsocketServiceInvoker(Operation operation, RuntimeEndpoint endpoint) {
- this.operation = operation;
- this.endpoint = endpoint;
- }
-
- public WebsocketBindingMessage invokeSync(WebsocketBindingMessage request) {
- String jsonParams = request.getPayload();
- Object[] args = JSONUtil.decodePayloadForOperation(jsonParams, operation);
- try {
- Object operationResponse = endpoint.invoke(operation, args);
- String payload = JSONUtil.encodePayload(operationResponse);
- WebsocketBindingMessage response = new WebsocketBindingMessage(request.getOperation(), payload);
- return response;
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void invokeAsync(WebsocketBindingMessage request, TuscanyWebsocket channel) {
- String jsonParams = request.getPayload();
- Object[] args = JSONUtil.decodePayloadForOperation(jsonParams, operation);
- Message msg = new MessageImpl();
- msg.getHeaders().put(Constants.MESSAGE_ID, channel.getId());
- msg.setBody(args);
- EndpointReference re = new RuntimeEndpointReferenceImpl();
- RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
- callbackEndpoint.setURI(request.getOperation());
- re.setCallbackEndpoint(callbackEndpoint);
- msg.setFrom(re);
- endpoint.invoke(operation, msg);
- }
-
- public boolean isNonBlocking() {
- return operation.isNonBlocking();
- }
-
-}
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStatus.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStatus.java deleted file mode 100644 index bb89761459..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketStatus.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.apache.tuscany.sca.binding.websocket.runtime; - -/** - * The websocket status indicates the state of a websocket connection when a - * send operation is performed. - */ -public enum WebsocketStatus { - OPEN, CLOSED -} 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 deleted file mode 100644 index 4ec8ba4eb2..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.websocket.WebsocketBindingFactory +++ /dev/null @@ -1,20 +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.
-
-# 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 deleted file mode 100644 index fd2e21a468..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,20 +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.
-
-# 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 deleted file mode 100644 index d4a7646f48..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema +++ /dev/null @@ -1,19 +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.
-#
-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 deleted file mode 100644 index e97707636d..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory +++ /dev/null @@ -1,20 +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.
-
-# 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 deleted file mode 100644 index 8ed0011361..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/binding-websocket.xsd +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
- elementFormDefault="qualified">
-
- <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" />
-
- <element name="binding.websocket" type="t:WebsocketBinding" substitutionGroup="sca:binding"/>
-
- <complexType name="WebsocketBinding">
- <complexContent>
- <extension base="sca:Binding">
- <attribute name="port" type="string" use="optional"/>
- </extension>
- </complexContent>
- </complexType>
-</schema>
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js b/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js deleted file mode 100644 index ede28579d3..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/resources/js/TuscanyWebsocketToolkit.js +++ /dev/null @@ -1,51 +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. - */ - -var channels = []; - -function buildRequest(operation, message) { - return JSON.stringify({ - operation: operation, - payload: JSON.stringify(message) - }); -} - -function sendMessage(port, operation, message) { - if (!channels[port]) { - ws = new WebSocket("ws://" + window.location.hostname + ":" + port); - channels[port] = ws; - ws.onopen = function() { - $(document).trigger('' + port); - } - ws.onmessage = function (message) { - var response = eval('(' + message.data + ')'); - eval('Tuscany.WebsocketComponentContext.' + response.operation + '.responseHandler(' + response.payload + ')'); - } - } - - var jsonReq = buildRequest(operation, message); - - if (ws.readyState == WebSocket.CONNECTING) { - $(document).bind('' + port, jsonReq, function(event) { - ws.send(event.data); - }); - } else if (ws.readyState == WebSocket.OPEN) { - ws.send(jsonReq); - } -}
\ No newline at end of file diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationService.java deleted file mode 100644 index f6cb155023..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationService.java +++ /dev/null @@ -1,34 +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 async; - -import org.apache.tuscany.sca.binding.websocket.runtime.WebsocketBindingCallback; -import org.oasisopen.sca.annotation.Callback; -import org.oasisopen.sca.annotation.OneWay; -import org.oasisopen.sca.annotation.Remotable; - -@Remotable -@Callback(WebsocketBindingCallback.class) -public interface NotificationService { - - @OneWay - void registerForNotifications(); - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationServiceImpl.java deleted file mode 100644 index 3350e7bd5f..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/async/NotificationServiceImpl.java +++ /dev/null @@ -1,50 +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 async; - -import java.util.Date; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.tuscany.sca.binding.websocket.runtime.WebsocketBindingCallback; -import org.apache.tuscany.sca.binding.websocket.runtime.WebsocketStatus; -import org.oasisopen.sca.annotation.Callback; -import org.oasisopen.sca.annotation.Service; - -@Service(NotificationService.class) -public class NotificationServiceImpl implements NotificationService { - - @Callback - protected WebsocketBindingCallback client; - - @Override - public void registerForNotifications() { - new Timer().scheduleAtFixedRate(new TimerTask() { - - @Override - public void run() { - WebsocketStatus status = client.sendMessage("Notification @ " + new Date()); - if (status == WebsocketStatus.CLOSED) { - this.cancel(); - } - } - }, 0L, 1000L); - } -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloService.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloService.java deleted file mode 100644 index 3e205c8148..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloService.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 sync; - -import org.oasisopen.sca.annotation.Remotable; - -@Remotable -public interface HelloService { - - String sayHello(String name); - -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloServiceImpl.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloServiceImpl.java deleted file mode 100644 index ee55d1db78..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/sync/HelloServiceImpl.java +++ /dev/null @@ -1,30 +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 sync; - -import org.oasisopen.sca.annotation.Service; - -@Service(HelloService.class) -public class HelloServiceImpl implements HelloService { - - @Override - public String sayHello(String name) { - return "Hello " + name; - } -} diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/testcase/WebsocketBindingTestCase.java b/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/testcase/WebsocketBindingTestCase.java deleted file mode 100644 index 318e2fdd01..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/java/testcase/WebsocketBindingTestCase.java +++ /dev/null @@ -1,59 +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 testcase; - -import junit.framework.Assert; - -import org.apache.tuscany.sca.http.jetty.JettyServer; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; -import org.junit.BeforeClass; -import org.junit.Test; - -public class WebsocketBindingTestCase { - - @BeforeClass - public static void init() { - JettyServer.portDefault = 8085; - } - - @Test - public void testSync() { - try { - Node node = NodeFactory.newInstance().createNode("sync.composite"); - node.start(); - node.stop(); - } catch (final Exception e) { - Assert.fail(e.getMessage()); - } - } - - @Test - public void testAsync() { - try { - Node node = NodeFactory.newInstance().createNode("async.composite"); - node.start(); - node.stop(); - } catch (final Exception e) { - Assert.fail(e.getMessage()); - } - } - -}
\ No newline at end of file diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/async.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/async.composite deleted file mode 100644 index 277cf17df2..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/async.composite +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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. ---> -<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" - targetNamespace="http://samples" - name="Async"> - - <component name="NotificationComponent"> - <implementation.java class="async.NotificationServiceImpl"/> - <service name="NotificationService"> - <interface.java interface="async.NotificationService" - callbackInterface="org.apache.tuscany.sca.binding.websocket.runtime.WebsocketBindingCallback"/> - <tuscany:binding.websocket/> - <callback> - <tuscany:binding.websocket/> - </callback> - </service> - </component> - -</composite> diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/sync.composite b/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/sync.composite deleted file mode 100644 index a4662cb2ee..0000000000 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/test/resources/sync.composite +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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. ---> -<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" - targetNamespace="http://samples" name="Sync"> - - <component name="HelloComponent"> - <implementation.java class="sync.HelloServiceImpl" /> - <service name="HelloService"> - <interface.java interface="sync.HelloService" /> - <tuscany:binding.websocket /> - </service> - </component> - -</composite>
\ No newline at end of file |