139bfb7b69e64181877d02fd5ac17cc2e491275b
[policy/drools-pdp.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * feature-distributed-locking
4  * ================================================================================
5  * Copyright (C) 2018 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 package org.onap.policy.distributed.locking;
21
22 import java.util.Properties;
23
24 import org.onap.policy.common.utils.properties.PropertyConfiguration;
25 import org.onap.policy.common.utils.properties.exception.PropertyException;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29
30 public class DistributedLockingProperties extends PropertyConfiguration{
31         
32         private static final Logger  logger = LoggerFactory.getLogger(DistributedLockingProperties.class);
33         
34         /**
35      * Feature properties all begin with this prefix.
36      */
37     public static final String PREFIX = "distributed.locking.";
38     
39         public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
40         public static final String DB_URL = "javax.persistence.jdbc.url";
41         public static final String DB_USER = "javax.persistence.jdbc.user";
42         public static final String DB_PWD = "javax.persistence.jdbc.password";
43         public static final String AGING_PROPERTY = PREFIX + "lock.aging";
44         public static final String HEARTBEAT_INTERVAL_PROPERTY = PREFIX + "heartbeat.interval";
45         
46         /**
47      * Properties from which this was constructed.
48      */
49     private Properties source;
50
51     /**
52      * Database driver
53      */
54     @Property(name = DB_DRIVER)
55     private String dbDriver;
56     
57     /**
58      * Database url
59      */
60     @Property(name = DB_URL)
61     private String dbUrl;
62     
63     /**
64      * Database user
65      */
66     @Property(name = DB_USER)
67     private String dbUser;
68     
69     /**
70      * Database password
71      */
72     @Property(name = DB_PWD)
73     private String dbPwd;
74     
75     /**
76      * Used to set expiration time for lock.
77      */
78     @Property(name = AGING_PROPERTY, defaultValue = "300000")
79     private long agingProperty;
80     
81     /**
82      * Indicates intervals at which we refresh locks.
83      */
84     @Property(name = HEARTBEAT_INTERVAL_PROPERTY, defaultValue = "60000")
85     private long heartBeatIntervalProperty;
86
87     public DistributedLockingProperties(Properties props) throws PropertyException {
88         super(props);
89         source = props;
90     }
91
92
93         public Properties getSource() {
94                 return source;
95         }
96
97
98         public String getDbDriver() {
99                 return dbDriver;
100         }
101
102
103         public String getDbUrl() {
104                 return dbUrl;
105         }
106
107
108         public String getDbUser() {
109                 return dbUser;
110         }
111
112
113         public String getDbPwd() {
114                 return dbPwd;
115         }
116
117
118         public long getAgingProperty() {
119                 return agingProperty;
120         }
121
122
123         public long getHeartBeatIntervalProperty() {
124                 return heartBeatIntervalProperty;
125         }
126
127 }