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 */
016 package org.opengion.fukurou.db;
017
018 import 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 */
041 public class TransactionReal extends TransactionImpl {
042 //public class TransactionReal implements Transaction {
043 // private final Connection conn ;
044 // private final String dbid ;
045 // private ApplicationInfo appInfo = null;
046 // private String dbid = null;
047 // private Connection conn = null; // 5.3.7.0 (2011/07/01) ?? close するように変更します?
048
049 /**
050 * ApplicationInfo を指定して作?する、コンストラクター
051 *
052 * こ?クラスは、トランザクション処?しな??合に、従来の Connection の
053 * 代わりに使用することを想定したクラスのオブジェクトを作?します?
054 *
055 * @og.rev 5.3.7.0 (2011/07/01) dbidを引数から削除
056 * @og.rev 5.3.8.0 (2011/08/01) 親クラスを呼ぶように変更
057 *
058 * @param appInfo ?統制用のアクセス??
059 */
060 // public TransactionReal( final String dbid , final ApplicationInfo appInfo ) {
061 public TransactionReal( final ApplicationInfo appInfo ) {
062 super( appInfo );
063 // this.appInfo = appInfo;
064 // this.dbid = dbid;
065 // this.conn = ConnectionFactory.connection( dbid,appInfo );
066 }
067
068 /**
069 * 呼ばれる都度、新しい Connection を返します?ただし?Connection 自身は?
070 * ConnectionFactory から取得するため?基本?はキャ?ュされたConnectionです?
071 *
072 * @og.rev 5.3.7.0 (2011/07/01) dbidチェ?
073 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソ?を呼ぶ為、?
074 *
075 * @param dbid 接続?ID (こ?クラスでは無視されま?
076 *
077 * @return ??DBID に対応した?Connection オブジェク?
078 */
079 // public Connection getConnection( final String dbid ) {
080 // if( conn != null ) { close(); }
081 //
082 // this.dbid = dbid;
083 // this.conn = ConnectionFactory.connection( dbid,appInfo );
084 // return conn ;
085 // }
086
087 /**
088 * コミット??行います?
089 *
090 * これは、呼ばれる都度、リアルタイ?処?ます?
091 *
092 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソ?を呼ぶ為、?
093 *
094 * @return 正常:true/異常:false
095 */
096 // public boolean commit() {
097 // return Closer.commit( conn );
098 // }
099
100 /**
101 * ロールバック処?行います?
102 *
103 * これは、呼ばれる都度、リアルタイ?処?ます?
104 *
105 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソ?を呼ぶ為、?
106 *
107 * @return 正常:true/異常:false
108 */
109 // public boolean rollback() {
110 // return Closer.rollback( conn );
111 // }
112
113 /**
114 * トランザクションの、終?処?行います?
115 *
116 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソ?を呼ぶ為、?
117 *
118 * @see #close( boolean )
119 *
120 * @return 正常:true/異常:false
121 */
122 // public boolean close() {
123 // return close( false );
124 // }
125
126 /**
127 * コネクションの、終?処?行います?
128 *
129 * 引数は、正常かど?を判定するフラグです?異常の場合?、true をセ?します?
130 * これは、ConnectionFactory のプ?ルに戻すかど?を判断するのに使われます?
131 * ?でも?エラーが発生したコネクションは、??ます?
132 * それ以外?、?ールに戻します?
133 *
134 * @og.rev 5.3.7.0 (2011/07/01) close時に、コネクション?null 化しておく?
135 * @og.rev 5.3.8.0 (2011/08/01) 終???行い、親クラスのrealClose() を呼ぶ?
136 *
137 * @param errFlag [true:エラー状?false:通常]
138 *
139 * @return 正常:true/異常:false
140 */
141 @Override
142 public boolean close( final boolean errFlag ) {
143 // if( errFlag ) { ConnectionFactory.remove( conn,dbid ); } // 削除
144 // else { ConnectionFactory.close( conn,dbid ); } // 返却
145
146 // conn = null; // 5.3.7.0 (2011/07/01)
147 // return true;
148
149 // 5.3.8.0 (2011/08/01) 終???行い、親クラスのrealClose() を呼ぶ?
150 super.close( errFlag );
151 finish();
152 realClose();
153
154 return true;
155 }
156 }