    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 *     https://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 * @param <T> the type of the result of all set methods for method chaining
    036 * @since 2.0
    037 */
    038public interface DatabaseBuilderProperties<T> {
    039
    040    /**
    041     * Enables or disable auto commit mode. If enabled, the database configuration instance performs a commit after each
    042     * database update.
    043     *
    044     * @param f the value of the auto commit flag
    045     * @return a reference to this object for method chaining
    046     */
    047    T setAutoCommit(boolean f);
    048
    049    /**
    050     * Sets the name of this configuration instance. This property is needed if a single database table contains the data of
    051     * multiple configuration instances. Then SQL statements generated by the configuration contain an additional constraint
    052     * filtering the configuration name column for this name.
    053     *
    054     * @param name the name of this configuration instance
    055     * @return a reference to this object for method chaining
    056     */
    057    T setConfigurationName(String name);
    058
    059    /**
    060     * Sets the name of the table column containing the configuration name. This property is needed if a single database
    061     * table contains the data of multiple configuration instances. Then this column is used as discriminator to select a
    062     * specific configuration instance.
    063     *
    064     * @param name the column name
    065     * @return a reference to this method for method chaining
    066     */
    067    T setConfigurationNameColumn(String name);
    068
    069    /**
    070     * Sets the data source for the database configuration. All database connections are obtained from this data source.
    071     * This is a mandatory property.
    072     *
    073     * @param src the data source for the database configuration
    074     * @return a reference to this object for method chaining
    075     */
    076    T setDataSource(DataSource src);
    077
    078    /**
    079     * Sets the name of the table column containing configuration keys. This is a mandatory property.
    080     *
    081     * @param name the column name
    082     * @return a reference to this object for method chaining
    083     */
    084    T setKeyColumn(String name);
    085
    086    /**
    087     * Sets the name of the table containing configuration data. Database configuration will access this database table.
    088     * This is a mandatory property.
    089     *
    090     * @param name the name of the table with configuration data
    091     * @return a reference to this object for method chaining
    092     */
    093    T setTable(String name);
    094
    095    /**
    096     * Sets the name of the table column containing the configuration property value. This is a mandatory property.
    097     *
    098     * @param name the column name
    099     * @return a reference to this object for method chaining
    100     */
    101    T setValueColumn(String name);
    102}