2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.core.infrastructure.messaging.impl.ws.client;
24 import org.java_websocket.client.WebSocketClient;
25 import org.java_websocket.handshake.ServerHandshake;
26 import org.slf4j.ext.XLogger;
27 import org.slf4j.ext.XLoggerFactory;
30 * This class implements {@link WebSocketClient} specific methods in order to act as a Java Web Socket client.
32 * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
34 abstract class WebSocketClientImpl extends WebSocketClient {
35 // The logger for this class
36 private static final XLogger LOGGER = XLoggerFactory.getXLogger(WebSocketClientImpl.class);
39 * Constructs a WebSocketClient instance and sets it to the connect to the specified URI. The channel does not
40 * attempt to connect automatically. You must call {@link connect} first to initiate the socket connection.
42 * @param serverUri the URI of the web socket server to connect to
44 WebSocketClientImpl(final URI serverUri) {
52 public void onOpen(final ServerHandshake handshakedata) {
53 if (LOGGER.isDebugEnabled()) {
54 LOGGER.debug("Connection opened to server {} --> {}", this.getURI(), handshakedata.getHttpStatusMessage());
62 public void onClose(final int code, final String reason, final boolean remote) {
63 if (LOGGER.isDebugEnabled()) {
64 LOGGER.debug("Connection closed to server {} --> code \"{}\", reason \"{}\"", this.getURI(), code, reason);
72 public void onError(final Exception ex) {
73 LOGGER.info("Failed to make a connection to the server {} ", getURI());