    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
    024 * configuration.
    025 * </p>
    026 * <p>
    027 * The properties defined by this interface are used to configure a
    028 * {@code DatabaseConfiguration} instance. They mainly specify the database
    029 * tables containing configuration properties. Note that many properties are
    030 * mandatory; they must be provided, otherwise the builder for database
    031 * configurations throws an exception.
    032 * </p>
    033 * <p>
    034 * <strong>Important note:</strong> This interface is not intended to be
    035 * implemented by client code! It defines a set of available properties and may
    036 * be extended even in minor releases.
    037 * </p>
    038 *
    039 * @since 2.0
    040 * @param <T> the type of the result of all set methods for method chaining
    041 */
    042public interface DatabaseBuilderProperties<T>
    043{
    044    /**
    045     * Sets the data source for the database configuration. All database
    046     * connections are obtained from this data source. This is a mandatory
    047     * property.
    048     *
    049     * @param src the data source for the database configuration
    050     * @return a reference to this object for method chaining
    051     */
    052    T setDataSource(DataSource src);
    053
    054    /**
    055     * Sets the name of the table containing configuration data. Database
    056     * configuration will access this database table. This is a mandatory
    057     * property.
    058     *
    059     * @param tname the name of the table with configuration data
    060     * @return a reference to this object for method chaining
    061     */
    062    T setTable(String tname);
    063
    064    /**
    065     * Sets the name of the table column containing configuration keys. This is
    066     * a mandatory property.
    067     *
    068     * @param name the column name
    069     * @return a reference to this object for method chaining
    070     */
    071    T setKeyColumn(String name);
    072
    073    /**
    074     * Sets the name of the table column containing the configuration property
    075     * value. This is a mandatory property.
    076     *
    077     * @param name the column name
    078     * @return a reference to this object for method chaining
    079     */
    080    T setValueColumn(String name);
    081
    082    /**
    083     * Sets the name of the table column containing the configuration name. This
    084     * property is needed if a single database table contains the data of
    085     * multiple configuration instances. Then this column is used as
    086     * discriminator to select a specific configuration instance.
    087     *
    088     * @param name the column name
    089     * @return a reference to this method for method chaining
    090     */
    091    T setConfigurationNameColumn(String name);
    092
    093    /**
    094     * Sets the name of this configuration instance. This property is needed if
    095     * a single database table contains the data of multiple configuration
    096     * instances. Then SQL statements generated by the configuration contain an
    097     * additional constraint filtering the configuration name column for this
    098     * name.
    099     *
    100     * @param name the name of this configuration instance
    101     * @return a reference to this object for method chaining
    102     */
    103    T setConfigurationName(String name);
    104
    105    /**
    106     * Enables or disable auto commit mode. If enabled, the database
    107     * configuration instance performs a commit after each database update.
    108     *
    109     * @param f the value of the auto commit flag
    110     * @return a reference to this object for method chaining
    111     */
    112    T setAutoCommit(boolean f);
    113}