001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration2.builder;
018
019import javax.sql.DataSource;
020
021/**
022 * <p>
023 * Definition of a properties interface for parameters of a database configuration.
024 * </p>
025 * <p>
026 * The properties defined by this interface are used to configure a {@code DatabaseConfiguration} instance. They mainly
027 * specify the database tables containing configuration properties. Note that many properties are mandatory; they must
028 * be provided, otherwise the builder for database configurations throws an exception.
029 * </p>
030 * <p>
031 * <strong>Important note:</strong> This interface is not intended to be implemented by client code! It defines a set of
032 * available properties and may be extended even in minor releases.
033 * </p>
034 *
035 * @since 2.0
036 * @param <T> the type of the result of all set methods for method chaining
037 */
038public interface DatabaseBuilderProperties<T> {
039    /**
040     * Sets the data source for the database configuration. All database connections are obtained from this data source.
041     * This is a mandatory property.
042     *
043     * @param src the data source for the database configuration
044     * @return a reference to this object for method chaining
045     */
046    T setDataSource(DataSource src);
047
048    /**
049     * Sets the name of the table containing configuration data. Database configuration will access this database table.
050     * This is a mandatory property.
051     *
052     * @param tname the name of the table with configuration data
053     * @return a reference to this object for method chaining
054     */
055    T setTable(String tname);
056
057    /**
058     * Sets the name of the table column containing configuration keys. This is a mandatory property.
059     *
060     * @param name the column name
061     * @return a reference to this object for method chaining
062     */
063    T setKeyColumn(String name);
064
065    /**
066     * Sets the name of the table column containing the configuration property value. This is a mandatory property.
067     *
068     * @param name the column name
069     * @return a reference to this object for method chaining
070     */
071    T setValueColumn(String name);
072
073    /**
074     * Sets the name of the table column containing the configuration name. This property is needed if a single database
075     * table contains the data of multiple configuration instances. Then this column is used as discriminator to select a
076     * specific configuration instance.
077     *
078     * @param name the column name
079     * @return a reference to this method for method chaining
080     */
081    T setConfigurationNameColumn(String name);
082
083    /**
084     * Sets the name of this configuration instance. This property is needed if a single database table contains the data of
085     * multiple configuration instances. Then SQL statements generated by the configuration contain an additional constraint
086     * filtering the configuration name column for this name.
087     *
088     * @param name the name of this configuration instance
089     * @return a reference to this object for method chaining
090     */
091    T setConfigurationName(String name);
092
093    /**
094     * Enables or disable auto commit mode. If enabled, the database configuration instance performs a commit after each
095     * database update.
096     *
097     * @param f the value of the auto commit flag
098     * @return a reference to this object for method chaining
099     */
100    T setAutoCommit(boolean f);
101}