/*
 * $Header: /home/cvs/commons/dbcp-1.0/ja/src/org/apache/commons/dbcp/AbandonedConfig.java,v 1.1.1.1 2004/02/13 10:02:03 hioki Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/02/13 10:02:03 $ 
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.commons.dbcp;

/**                                                   
 * 破棄されたデータベースコネクションを処理するための設定情報です。
 * {@primary Configuration settings for handling abandoned db connections.}
 *                                                            
 * @author Glenn L. Nielsen           
 * @translator 日置 聡
 * @status firstdraft
 * @update 2003/09/13
 * @version $Revision: 1.1.1.1 $ $Date: 2004/02/13 10:02:03 $
 */
public class AbandonedConfig {

    private boolean removeAbandoned = false;

    /**
     * removeAbandonedTimeout を超えた場合に破棄されたコネクションを削除するかどうかのフラグです。
     *
     * true か false を設定してください。デフォルトは false です。
     * true を設定した場合、アイドル時間が removeAbandonedTimeout 
     * を超えたコネクションは破棄され、削除されるべきであるとみなされます。
     * true を設定することによりコネクションのクローズ処理を失敗したときの処理があまり考慮されていない
     * アプリケーションのデータベースコネクションを回復させることができます。
     *
     * {@primary Flag to remove abandoned connections if they exceed the
     * removeAbandonedTimeout.
     *
     * Set to true or false, default false.
     * If set to true a connection is considered abandoned and eligible
     * for removal if it has been idle longer than the removeAbandonedTimeout.
     * Setting this to true can recover db connections from poorly written    
     * applications which fail to close a connection.}
     *
     * @return boolean
     */
    public boolean getRemoveAbandoned() {
        return (this.removeAbandoned);
    }

    /**
     * removeAbandonedTimeout を超えた場合に破棄されたコネクションを削除するかどうかのフラグです。
     *
     * true か false を設定してください。デフォルトは false です。
     * true を設定した場合、アイドル時間が removeAbandonedTimeout 
     * を超えたコネクションは破棄され、削除されるべきであるとみなされます。
     * true を設定することによりコネクションのクローズ処理を失敗したときの処理があまり考慮されていない
     * アプリケーションのデータベースコネクションを回復させることができます。
     *
     * {@primary Flag to remove abandoned connections if they exceed the
     * removeAbandonedTimeout.
     *
     * Set to true or false, default false.
     * If set to true a connection is considered abandoned and eligible
     * for removal if it has been idle longer than the removeAbandonedTimeout.
     * Setting this to true can recover db connections from poorly written    
     * applications which fail to close a connection.}
     *
     * @param removeAbandoned
     */
    public void setRemoveAbandoned(boolean removeAbandoned) {
        this.removeAbandoned = removeAbandoned;
    }

    private int removeAbandonedTimeout = 300;

    /**
     * 破棄されたコネクションを削除する処理のタイムアウト時間(秒)です。
     * デフォルトは300秒です。
     * {@primary Timeout in seconds before an abandoned connection can be removed.
     *
     * Defaults to 300 seconds.}
     *
     * @return 破棄されたコネクションを削除する処理のタイムアウト時間(秒)
     * {@primary int remove abandoned timeout in seconds}
     */
    public int getRemoveAbandonedTimeout() {
        return (this.removeAbandonedTimeout);
    }

    /**
     * 破棄されたコネクションを削除する処理のタイムアウト時間(秒)です。
     * デフォルトは300秒です。
     * {@primary Timeout in seconds before an abandoned connection can be removed.
     *
     * Defaults to 300 seconds.}
     *
     * @param removeAbandonedTimeout 破棄されたコネクションを削除する処理のタイムアウト時間(秒)
     * {@primary remove abandoned timeout in seconds}
     */
    public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
        this.removeAbandonedTimeout = removeAbandonedTimeout;
    }

    private boolean logAbandoned = false;

    /**
     * ステートメントまたはコネクションを破棄したアプリケーションのスタックトレースをログするかどうかのフラグです。
     * デフォルトの値は false です。
     * 破棄されたステートメントまたはコネクションのログ処理は
     * 全てのコネクションを開く処理またはステートメントの生成時にスタックトレースを生成するためオーバヘッドを与えます。
     *
     * {@primary Flag to log stack traces for application code which abandoned
     * a Statement or Connection.
     *
     * Defaults to false.
     *
     * Logging of abandoned Statements and Connections adds overhead
     * for every Connection open or new Statement because a stack
     * trace has to be generated.}
     *
     * @return boolean
     */
    public boolean getLogAbandoned() {
        return (this.logAbandoned);
    }

    /**
     * ステートメントまたはコネクションを破棄したアプリケーションのスタックトレースをログするかどうかのフラグです。
     * デフォルトの値は false です。
     * 破棄されたステートメントまたはコネクションのログ処理は
     * 全てのコネクションを開く処理またはステートメントの生成時にスタックトレースを生成するためオーバヘッドを与えます。
     *
     * {@primary Flag to log stack traces for application code which abandoned
     * a Statement or Connection.
     *
     * Defaults to false.
     * Logging of abandoned Statements and Connections adds overhead
     * for every Connection open or new Statement because a stack
     * trace has to be generated.}
     *
     * @param logAbandoned
     */
    public void setLogAbandoned(boolean logAbandoned) {
        this.logAbandoned = logAbandoned;
    }

}
