2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020-2021 Nordix Foundation.
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.gui.pdp.monitoring;
26 import lombok.ToString;
27 import org.onap.policy.common.parameters.BeanValidator;
28 import org.onap.policy.common.parameters.ValidationResult;
29 import org.onap.policy.common.parameters.annotations.Max;
30 import org.onap.policy.common.parameters.annotations.Min;
33 * This class reads and handles command line parameters to the Pdp Monitoring services.
35 * @author Yehui Wang (yehui.wang@est.tech)
40 public class PdpMonitoringServerParameters {
41 public static final int INFINITY_TIME_TO_LIVE = -1;
43 // Base URI the HTTP server will listen on
44 private static final String DEFAULT_SERVER_URI_ROOT = "http://0.0.0.0:";
45 private static final String DEFAULT_REST_PATH = "papservices/*";
46 private static final String DEFAULT_CONTEXT_PATH = "/";
47 private static final String SERVER_HOST = "0.0.0.0";
48 private static final int DEFAULT_REST_PORT = 17999;
49 // Package that will field REST requests
50 private static final String DEFAULT_REST_PACKAGE = "org.onap.policy.gui.pdp.monitoring.rest";
52 // The services parameters
53 private boolean helpSet = false;
57 private int port = DEFAULT_REST_PORT;
60 private long timeToLive = INFINITY_TIME_TO_LIVE;
63 * Validate the parameters.
65 * @return the result of the validation
67 public ValidationResult validate() {
68 return new BeanValidator().validateTop(PdpMonitoringServerParameters.class.getSimpleName(), this);
71 public URI getBaseUri() {
72 return URI.create(DEFAULT_SERVER_URI_ROOT + port + "/" + DEFAULT_REST_PATH);
75 public String getRestPackage() {
76 return DEFAULT_REST_PACKAGE;
79 public String getContextPath() {
80 return DEFAULT_CONTEXT_PATH;
83 public String getServerHost() {
87 public String getDefaultRestPath() {
88 return "/" + DEFAULT_REST_PATH;