2 * ============LICENSE_START=======================================================
3 * feature-distributed-locking
4 * ================================================================================
5 * Copyright (C) 2018-2019 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.distributed.locking;
23 import java.util.Properties;
26 import org.onap.policy.common.utils.properties.BeanConfigurator;
27 import org.onap.policy.common.utils.properties.Property;
28 import org.onap.policy.common.utils.properties.exception.PropertyException;
33 public class DistributedLockProperties {
34 public static final String PREFIX = "distributed.locking.";
36 public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
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_PASS = "javax.persistence.jdbc.password";
40 public static final String EXPIRE_CHECK_SEC = PREFIX + "expire.check.seconds";
41 public static final String RETRY_SEC = PREFIX + "retry.seconds";
42 public static final String MAX_RETRIES = PREFIX + "max.retries";
47 @Property(name = DB_DRIVER)
48 private String dbDriver;
53 @Property(name = DB_URL)
59 @Property(name = DB_USER)
60 private String dbUser;
65 @Property(name = DB_PASS)
69 * Time, in seconds, to wait between checks for expired locks.
71 @Property(name = EXPIRE_CHECK_SEC, defaultValue = "900")
72 private int expireCheckSec;
75 * Number of seconds to wait before retrying, after a DB error.
77 @Property(name = RETRY_SEC, defaultValue = "60")
81 * Maximum number of times to retry a DB operation.
83 @Property(name = MAX_RETRIES, defaultValue = "2")
84 private int maxRetries;
87 * Constructs the object, populating fields from the properties.
89 * @param props properties from which to configure this
90 * @throws PropertyException if an error occurs
92 public DistributedLockProperties(Properties props) throws PropertyException {
93 new BeanConfigurator().configureFromProperties(this, props);