7e2388e552017602c71b09f52d6a2a3ed2c6aeff
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-persistence
4  * ================================================================================
5  * Copyright (C) 2017 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.openecomp.policy.drools.persistence;
22
23 import java.util.Properties;
24
25 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
26 import org.openecomp.policy.common.logging.flexlogger.Logger;
27
28
29 public class XacmlPersistenceProperties {
30         // get an instance of logger 
31         private static Logger  logger = FlexLogger.getLogger(XacmlPersistenceProperties.class); 
32         /*
33          * xacmlPersistence.properties parameter key values
34          */
35         public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
36         public static final String DB_DATA_SOURCE  = "hibernate.dataSource";
37         public static final String DB_URL = "javax.persistence.jdbc.url";
38         public static final String DB_USER = "javax.persistence.jdbc.user";
39         public static final String DB_PWD = "javax.persistence.jdbc.password";
40                 
41         private static Properties properties = null;
42         /*
43          * Initialize the parameter values from the droolsPersitence.properties file values
44          * 
45          * This is designed so that the Properties object is obtained from the xacmlPersistence.properties
46          * file and then is passed to this method to initialize the value of the parameters.
47          * This allows the flexibility of JUnit tests using getProperties(filename) to get the
48          * properties while runtime methods can use getPropertiesFromClassPath(filename).
49          * 
50          */
51         public static void initProperties (Properties prop){
52                 logger.info("XacmlPersistenceProperties.initProperties(Properties): entry");
53                 logger.info("\n\nXacmlPersistenceProperties.initProperties: Properties = \n" + prop + "\n\n");
54                 
55                 properties = prop;
56         }
57
58         public static String getProperty(String key){
59                 return properties.getProperty(key);
60         }
61         
62         public static Properties getProperties() {
63                 return properties;
64         }
65 }