2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.plugins.event.carrier.websocket;
24 import org.apache.commons.lang3.StringUtils;
25 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
26 import org.onap.policy.common.parameters.BeanValidationResult;
27 import org.onap.policy.common.parameters.ValidationStatus;
28 import org.onap.policy.common.parameters.annotations.Max;
29 import org.onap.policy.common.parameters.annotations.Min;
30 import org.onap.policy.models.base.Validated;
33 * Apex parameters for Kafka as an event carrier technology.
35 * @author Liam Fallon (liam.fallon@ericsson.com)
37 public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters {
39 private static final int MIN_USER_PORT = 1024;
40 private static final int MAX_USER_PORT = 65535;
42 /** The label of this carrier technology. */
43 public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET";
45 /** The producer plugin class for the web socket carrier technology. */
46 public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getName();
48 /** The consumer plugin class for the web socket carrier technology. */
49 public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getName();
51 // Default parameter values
52 private static final String DEFAULT_HOST = "localhost";
53 private static final int DEFAULT_PORT = -1;
55 // Web socket parameters
56 private boolean wsClient = true;
57 private String host = DEFAULT_HOST;
60 private int port = DEFAULT_PORT;
64 * Constructor to create a web socket carrier technology parameters instance and register the instance with the
67 public WebSocketCarrierTechnologyParameters() {
70 // Set the carrier technology properties for the web socket carrier technology
71 this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
72 this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS);
73 this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS);
81 public String getHost() {
90 public int getPort() {
95 * Checks if is ws client.
97 * @return true, if checks if is ws client
99 public boolean isWsClient() {
107 public BeanValidationResult validate() {
108 final BeanValidationResult result = super.validate();
110 if (wsClient && StringUtils.isBlank(host)) {
111 result.addResult("host", host, ValidationStatus.INVALID, Validated.IS_BLANK);