Remove IdlLightConfig.log()
[aaa.git] / aaa-idm-store-h2 / src / main / java / org / opendaylight / aaa / datastore / h2 / IdmLightConfig.java
1 /*
2  * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.aaa.datastore.h2;
9
10 import com.google.common.base.MoreObjects;
11 import java.io.File;
12 import org.immutables.value.Value;
13 import org.immutables.value.Value.Default;
14 import org.immutables.value.Value.Immutable;
15 import org.immutables.value.Value.Style.ImplementationVisibility;
16
17 /**
18  * Responsible for providing configuration properties for the IDMLight/H2 data store implementation.
19  *
20  * @author peter.mellquist@hp.com - Initial contribution
21  * @author Michael Vorburger.ch - Made it configurable, as Immutable with a Builder
22  */
23 @Immutable
24 @Value.Style(strictBuilder = true, builder = "new",
25     typeImmutable = "*Impl", visibility = ImplementationVisibility.PRIVATE)
26 public abstract class IdmLightConfig {
27     /**
28      * The filename for the H2 database file.
29      *
30      * @return data base name
31      */
32     @Default
33     public String getDbName() {
34         return "idmlight.db";
35     }
36
37     /**
38      * The database directory for the h2 database file. Either absolute or
39      * relative to KARAF_HOME.
40      *
41      * @return data base dir
42      */
43     @Default
44     public String getDbDirectory() {
45         return "./data";
46     }
47
48     /**
49      * The database JDBC driver, default is H2; a pure-java implementation.
50      *
51      * @return data base driver
52      */
53     @Default
54     public String getDbDriver() {
55         return "org.h2.Driver";
56     }
57
58     /**
59      * The database username. This is not the same as AAA credentials!
60      *
61      * @return data base user
62      */
63     public abstract String getDbUser();
64
65     /**
66      * The database password. This is not the same as AAA credentials!
67      *
68      * @return data base password
69      */
70     public abstract String getDbPwd();
71
72     /**
73      * Timeout for database connections in seconds.
74      *
75      * @return data base valid time out
76      */
77     @Default
78     public int getDbValidTimeOut() {
79         return 3;
80     }
81
82     /**
83      * The JDBC default connection string.
84      *
85      * @return data base connection prefix
86      */
87     @Default
88     public String getDbConnectionStringPrefix() {
89         return "jdbc:h2:";
90     }
91
92     /**
93      * The JDBC database connection string.
94      *
95      * @return data base connection
96      */
97     @Default
98     public String getDbConnectionString() {
99         return getDbConnectionStringPrefix() + getDbDirectory() + File.separatorChar + getDbName();
100     }
101
102     @Override
103     public final String toString() {
104         return MoreObjects.toStringHelper(this)
105             .add("path", getDbConnectionString())
106             .add("driver", getDbDriver())
107             .add("validity timeout", getDbValidTimeOut())
108             .toString();
109     }
110 }