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;
25 import org.java_websocket.client.WebSocketClient;
26 import org.java_websocket.handshake.ServerHandshake;
27 import org.slf4j.ext.XLogger;
28 import org.slf4j.ext.XLoggerFactory;
31 * This class implements {@link WebSocketClient} specific methods in order to act as a Java Web Socket client.
33 * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
35 abstract class WebSocketClientImpl extends WebSocketClient {
36 // The logger for this class
37 private static final XLogger LOGGER = XLoggerFactory.getXLogger(WebSocketClientImpl.class);
40 * Constructs a WebSocketClient instance and sets it to the connect to the specified URI. The channel does not
41 * attempt to connect automatically. You must call {@link connect} first to initiate the socket connection.
43 * @param serverUri the URI of the web socket server to connect to
45 WebSocketClientImpl(final URI serverUri) {
53 public void onOpen(final ServerHandshake handshakedata) {
54 if (LOGGER.isDebugEnabled()) {
55 LOGGER.debug("Connection opened to server {} --> {}", this.getURI(), handshakedata.getHttpStatusMessage());
63 public void onClose(final int code, final String reason, final boolean remote) {
64 if (LOGGER.isDebugEnabled()) {
65 LOGGER.debug("Connection closed to server {} --> code \"{}\", reason \"{}\"", this.getURI(), code, reason);
73 public void onError(final Exception ex) {
74 LOGGER.info("Failed to make a connection to the server {} ", getURI());