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.plugins.event.carrier.websocket;
23 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
26 * Apex parameters for Kafka as an event carrier technology.
28 * @author Liam Fallon (liam.fallon@ericsson.com)
30 public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParameters {
32 private static final int MIN_USER_PORT = 1024;
33 private static final int MAX_USER_PORT = 65535;
35 /** The label of this carrier technology. */
36 public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET";
38 /** The producer plugin class for the web socket carrier technology. */
39 public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getCanonicalName();
41 /** The consumer plugin class for the web socket carrier technology. */
42 public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getCanonicalName();
44 // Default parameter values
45 private static final String DEFAULT_HOST = "localhost";
46 private static final int DEFAULT_PORT = -1;
48 // Web socket parameters
49 private boolean wsClient = true;
50 private String host = DEFAULT_HOST;
51 private int port = DEFAULT_PORT;
55 * Constructor to create a web socket carrier technology parameters instance and register the instance with the
58 public WEBSOCKETCarrierTechnologyParameters() {
59 super(WEBSOCKETCarrierTechnologyParameters.class.getCanonicalName());
61 // Set the carrier technology properties for the web socket carrier technology
62 this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
63 this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS);
64 this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS);
72 public String getHost() {
81 public int getPort() {
86 * Checks if is ws client.
88 * @return true, if checks if is ws client
90 public boolean isWsClient() {
97 * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
100 public String validate() {
101 final StringBuilder errorMessageBuilder = new StringBuilder();
103 errorMessageBuilder.append(super.validate());
105 if (wsClient && (host == null || host.trim().length() == 0)) {
106 errorMessageBuilder.append(" host not specified, must be host as a string\n");
109 if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
110 errorMessageBuilder.append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
113 return errorMessageBuilder.toString();