001/*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016package org.opengion.fukurou.db;
017
018import org.opengion.fukurou.util.ApplicationInfo;
019
020
021/**
022 * Transaction インターフェースを継承した、リアルタイムトランザクションクラスです。
023 *
024 * これは、通常のトランザクションクラスと異なり、トランザクション処理をしません。
025 * つまり、トランザクション処理を行わないときに、メソッド等の共通的な使用ができるようにする、
026 * Connection のラップクラスになります。
027 * ただし、このクラスが生成されてから、クローズされるまでは、内部に保留した Connection は、
028 * ずっと使い続けられますので、ConnectionFactory から取り出した Connection と同様に
029 * トランザクション性は維持されます。
030 * このクラスより作成された、Statement は、取り出し側で、きちんとクロース処理を
031 *
032 * このクラスでは、コミット、ロールバック、クローズ処理は、リアルタイムに行われます。
033 *
034 * @og.rev 5.1.9.0 (2010/08/01) 新規作成
035 * @og.rev 5.3.8.0 (2011/08/01) クラスの内部構造変更
036 *
037 * @version  5.0
038 * @author       Kazuhiko Hasegawa
039 * @since    JDK6.0,
040 */
041public class TransactionReal extends TransactionImpl {
042
043        /**
044         * ApplicationInfo を指定して作成する、コンストラクター
045         *
046         * このクラスは、トランザクション処理をしない場合に、従来の Connection の
047         * 代わりに使用することを想定したクラスのオブジェクトを作成します。
048         *
049         * @og.rev 5.3.7.0 (2011/07/01) dbidを引数から削除
050         * @og.rev 5.3.8.0 (2011/08/01) 親クラスを呼ぶように変更
051         *
052         * @param       appInfo 内部統制用のアクセス情報
053         */
054        public TransactionReal( final ApplicationInfo appInfo ) {
055                super( appInfo );
056        }
057
058        /**
059         * コネクションの、終了時処理を行います。
060         *
061         * 引数は、正常かどうかを判定するフラグです。異常の場合は、true をセットします。
062         * これは、ConnectionFactory のプールに戻すかどうかを判断するのに使われます。
063         * 一度でも、エラーが発生したコネクションは、破棄します。
064         * それ以外は、プールに戻します。
065         *
066         * @og.rev 5.3.7.0 (2011/07/01) close時に、コネクションを null 化しておく。
067         * @og.rev 5.3.8.0 (2011/08/01) 終了処理を行い、親クラスのrealClose() を呼ぶ。
068         *
069         * @param       errFlag  [true:エラー状態/false:通常]
070         *
071         * @return 正常:true/異常:false
072         */
073        @Override
074        public boolean close( final boolean errFlag ) {
075                // 5.3.8.0 (2011/08/01) 終了処理を行い、親クラスのrealClose() を呼ぶ。
076                super.close( errFlag );
077                finish();
078                realClose();
079
080                return true;
081        }
082}