summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java')
-rw-r--r--sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java95
1 files changed, 0 insertions, 95 deletions
diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java
deleted file mode 100644
index c33b3ca12a..0000000000
--- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebSocketOperationDispatcher.java
+++ /dev/null
@@ -1,95 +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.nio.channels.SocketChannel;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.websocket.ServerWebSocket;
-import org.apache.websocket.WebSocket;
-import org.apache.websocket.WebSocketApplication;
-import org.apache.websocket.WebSocketException;
-
-public class WebSocketOperationDispatcher implements WebSocketApplication<SocketChannel> {
-
- private ServerWebSocket server;
- private Map<String, RuntimeEndpoint> endpoints = new HashMap<String, RuntimeEndpoint>();
- private Map<String, Operation> operations = new HashMap<String, Operation>();
-
- public WebSocketOperationDispatcher(ServerWebSocket server) {
- this.server = server;
- }
-
- public void addOperation(String uri, RuntimeEndpoint endpoint, Operation operation) {
- endpoints.put(uri, endpoint);
- operations.put(uri, operation);
- }
-
- public Operation getOperation(String uri) {
- return operations.get(uri);
- }
-
- public RuntimeEndpoint getEndpoint(String uri) {
- return endpoints.get(uri);
- }
-
- @Override
- public void onConnection(WebSocket<SocketChannel> socket) {
- // release server thread
- new Thread(new WebSocketRequestHandler(socket, this)).start();
- }
-
- @Override
- public void onHandshakeError(IOException e) {
- throw new RuntimeException(e);
- }
-
- @Override
- public String acceptProtocol(String protocol) {
- // don't accept any subprotocols
- return null;
- }
-
- @Override
- public boolean acceptOrigin(String origin) {
- // accept all clients
- return true;
- }
-
- @Override
- public Map<String, String> acceptExtensions(Map<String, String> headers) throws WebSocketException {
- // don't accept any extensions
- return null;
- }
-
- public void shutdown() {
- try {
- server.close();
- endpoints.clear();
- operations.clear();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-} \ No newline at end of file