View Javadoc
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    *     http://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   * @since 2.0
36   * @param <T> the type of the result of all set methods for method chaining
37   */
38  public interface DatabaseBuilderProperties<T> {
39      /**
40       * Enables or disable auto commit mode. If enabled, the database configuration instance performs a commit after each
41       * database update.
42       *
43       * @param f the value of the auto commit flag
44       * @return a reference to this object for method chaining
45       */
46      T setAutoCommit(boolean f);
47  
48      /**
49       * Sets the name of this configuration instance. This property is needed if a single database table contains the data of
50       * multiple configuration instances. Then SQL statements generated by the configuration contain an additional constraint
51       * filtering the configuration name column for this name.
52       *
53       * @param name the name of this configuration instance
54       * @return a reference to this object for method chaining
55       */
56      T setConfigurationName(String name);
57  
58      /**
59       * Sets the name of the table column containing the configuration name. This property is needed if a single database
60       * table contains the data of multiple configuration instances. Then this column is used as discriminator to select a
61       * specific configuration instance.
62       *
63       * @param name the column name
64       * @return a reference to this method for method chaining
65       */
66      T setConfigurationNameColumn(String name);
67  
68      /**
69       * Sets the data source for the database configuration. All database connections are obtained from this data source.
70       * This is a mandatory property.
71       *
72       * @param src the data source for the database configuration
73       * @return a reference to this object for method chaining
74       */
75      T setDataSource(DataSource src);
76  
77      /**
78       * Sets the name of the table column containing configuration keys. This is a mandatory property.
79       *
80       * @param name the column name
81       * @return a reference to this object for method chaining
82       */
83      T setKeyColumn(String name);
84  
85      /**
86       * Sets the name of the table containing configuration data. Database configuration will access this database table.
87       * This is a mandatory property.
88       *
89       * @param name the name of the table with configuration data
90       * @return a reference to this object for method chaining
91       */
92      T setTable(String name);
93  
94      /**
95       * Sets the name of the table column containing the configuration property value. This is a mandatory property.
96       *
97       * @param name the column name
98       * @return a reference to this object for method chaining
99       */
100     T setValueColumn(String name);
101 }