1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.configuration2.builder;
18
19 import javax.sql.DataSource;
20
21 /**
22 * <p>
23 * Definition of a properties interface for parameters of a database configuration.
24 * </p>
25 * <p>
26 * The properties defined by this interface are used to configure a {@code DatabaseConfiguration} instance. They mainly
27 * specify the database tables containing configuration properties. Note that many properties are mandatory; they must
28 * be provided, otherwise the builder for database configurations throws an exception.
29 * </p>
30 * <p>
31 * <strong>Important note:</strong> This interface is not intended to be implemented by client code! It defines a set of
32 * available properties and may be extended even in minor releases.
33 * </p>
34 *
35 * @param <T> the type of the result of all set methods for method chaining
36 * @since 2.0
37 */
38 public interface DatabaseBuilderProperties<T> {
39
40 /**
41 * Enables or disable auto commit mode. If enabled, the database configuration instance performs a commit after each
42 * database update.
43 *
44 * @param f the value of the auto commit flag
45 * @return a reference to this object for method chaining
46 */
47 T setAutoCommit(boolean f);
48
49 /**
50 * Sets the name of this configuration instance. This property is needed if a single database table contains the data of
51 * multiple configuration instances. Then SQL statements generated by the configuration contain an additional constraint
52 * filtering the configuration name column for this name.
53 *
54 * @param name the name of this configuration instance
55 * @return a reference to this object for method chaining
56 */
57 T setConfigurationName(String name);
58
59 /**
60 * Sets the name of the table column containing the configuration name. This property is needed if a single database
61 * table contains the data of multiple configuration instances. Then this column is used as discriminator to select a
62 * specific configuration instance.
63 *
64 * @param name the column name
65 * @return a reference to this method for method chaining
66 */
67 T setConfigurationNameColumn(String name);
68
69 /**
70 * Sets the data source for the database configuration. All database connections are obtained from this data source.
71 * This is a mandatory property.
72 *
73 * @param src the data source for the database configuration
74 * @return a reference to this object for method chaining
75 */
76 T setDataSource(DataSource src);
77
78 /**
79 * Sets the name of the table column containing configuration keys. This is a mandatory property.
80 *
81 * @param name the column name
82 * @return a reference to this object for method chaining
83 */
84 T setKeyColumn(String name);
85
86 /**
87 * Sets the name of the table containing configuration data. Database configuration will access this database table.
88 * This is a mandatory property.
89 *
90 * @param name the name of the table with configuration data
91 * @return a reference to this object for method chaining
92 */
93 T setTable(String name);
94
95 /**
96 * Sets the name of the table column containing the configuration property value. This is a mandatory property.
97 *
98 * @param name the column name
99 * @return a reference to this object for method chaining
100 */
101 T setValueColumn(String name);
102 }