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