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;
25 import org.apache.commons.lang3.StringUtils;
26 import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
27 import org.onap.policy.common.parameters.BeanValidationResult;
28 import org.onap.policy.common.parameters.ValidationStatus;
29 import org.onap.policy.common.parameters.annotations.Max;
30 import org.onap.policy.common.parameters.annotations.Min;
31 import org.onap.policy.models.base.Validated;
34 * Apex parameters for Kafka as an event carrier technology.
36 * @author Liam Fallon (liam.fallon@ericsson.com)
39 public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters {
41 private static final int MIN_USER_PORT = 1024;
42 private static final int MAX_USER_PORT = 65535;
44 /** The label of this carrier technology. */
45 public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET";
47 /** The producer plugin class for the web socket carrier technology. */
48 public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getName();
50 /** The consumer plugin class for the web socket carrier technology. */
51 public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getName();
53 // Default parameter values
54 private static final String DEFAULT_HOST = "localhost";
55 private static final int DEFAULT_PORT = -1;
57 // Web socket parameters
58 private boolean wsClient = true;
59 private String host = DEFAULT_HOST;
62 private int port = DEFAULT_PORT;
66 * Constructor to create a web socket carrier technology parameters instance and register the instance with the
69 public WebSocketCarrierTechnologyParameters() {
72 // Set the carrier technology properties for the web socket carrier technology
73 this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
74 this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS);
75 this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS);
82 public BeanValidationResult validate() {
83 final BeanValidationResult result = super.validate();
85 if (wsClient && StringUtils.isBlank(host)) {
86 result.addResult("host", host, ValidationStatus.INVALID, Validated.IS_BLANK);