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;
24 import org.onap.policy.common.parameters.GroupValidationResult;
25 import org.onap.policy.common.parameters.ValidationStatus;
28 * Apex parameters for Kafka as an event carrier technology.
30 * @author Liam Fallon (liam.fallon@ericsson.com)
32 public class WebSocketCarrierTechnologyParameters extends CarrierTechnologyParameters {
34 private static final int MIN_USER_PORT = 1024;
35 private static final int MAX_USER_PORT = 65535;
37 /** The label of this carrier technology. */
38 public static final String WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL = "WEBSOCKET";
40 /** The producer plugin class for the web socket carrier technology. */
41 public static final String WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS = ApexWebSocketProducer.class.getCanonicalName();
43 /** The consumer plugin class for the web socket carrier technology. */
44 public static final String KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS = ApexWebSocketConsumer.class.getCanonicalName();
46 // Default parameter values
47 private static final String DEFAULT_HOST = "localhost";
48 private static final int DEFAULT_PORT = -1;
50 // Web socket parameters
51 private boolean wsClient = true;
52 private String host = DEFAULT_HOST;
53 private int port = DEFAULT_PORT;
57 * Constructor to create a web socket carrier technology parameters instance and register the instance with the
60 public WebSocketCarrierTechnologyParameters() {
63 // Set the carrier technology properties for the web socket carrier technology
64 this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
65 this.setEventProducerPluginClass(WEB_SCOKET_EVENT_PRODUCER_PLUGIN_CLASS);
66 this.setEventConsumerPluginClass(KWEB_SCOKET_EVENT_CONSUMER_PLUGIN_CLASS);
74 public String getHost() {
83 public int getPort() {
88 * Checks if is ws client.
90 * @return true, if checks if is ws client
92 public boolean isWsClient() {
99 * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
102 public GroupValidationResult validate() {
103 final GroupValidationResult result = super.validate();
105 if (wsClient && (host == null || host.trim().length() == 0)) {
106 result.setResult("host", ValidationStatus.INVALID, "host not specified, must be host as a string");
109 if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
110 result.setResult("port", ValidationStatus.INVALID,
111 "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");