30c8171e0a9e8276b7175c72c7e2c9737d4466ca
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * feature-active-standby-management
4  * ================================================================================
5  * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.drools.activestandby;
22
23 import java.util.Properties;
24 import lombok.AccessLevel;
25 import lombok.Getter;
26 import lombok.NoArgsConstructor;
27 import org.eclipse.persistence.config.PersistenceUnitProperties;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 @NoArgsConstructor(access = AccessLevel.PRIVATE)
32 public final class ActiveStandbyProperties {
33     // get an instance of logger
34     private static final Logger  logger = LoggerFactory.getLogger(ActiveStandbyProperties.class);
35
36     public static final String PDP_CHECK_INVERVAL = "pdp.checkInterval";
37     public static final String PDP_UPDATE_INTERVAL = "pdp.updateInterval";
38     public static final String PDP_TIMEOUT = "pdp.timeout";
39     public static final String PDP_INITIAL_WAIT_PERIOD = "pdp.initialWait";
40
41     public static final String NODE_NAME = "resource.name";
42     public static final String SITE_NAME = "site_name";
43
44     /*
45      * feature-active-standby-management.properties parameter key values
46      */
47     public static final String DB_DRIVER = PersistenceUnitProperties.JDBC_DRIVER;
48     public static final String DB_URL = PersistenceUnitProperties.JDBC_URL;
49     public static final String DB_USER = PersistenceUnitProperties.JDBC_USER;
50     public static final String DB_PWD = PersistenceUnitProperties.JDBC_PASSWORD;
51     public static final String DB_TYPE = PersistenceUnitProperties.TARGET_DATABASE;
52
53     @Getter
54     private static Properties properties = null;
55
56     /**
57      * Initialize the parameter values from the droolsPersitence.properties file values.
58      *
59      * <p>This is designed so that the Properties object is obtained from properties
60      * file and then is passed to this method to initialize the value of the parameters.
61      * This allows the flexibility of JUnit tests using getProperties(filename) to get the
62      * properties while runtime methods can use getPropertiesFromClassPath(filename).
63      *
64      * @param prop properties
65      */
66     public static void initProperties(Properties prop) {
67         logger.info("ActiveStandbyProperties.initProperties(Properties): entry");
68         logger.info("\n\nActiveStandbyProperties.initProperties: Properties = \n{}\n\n", prop);
69
70         properties = prop;
71     }
72
73     public static String getProperty(String key) {
74         return properties.getProperty(key);
75     }
76 }