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 <del>と、DBID</del>を指定して作æ?する、コンストラクター
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 * <del>å†?ƒ¨キャãƒ?‚·ュされてã�?‚‹、Connection オブジェクトを返しますã?</del>
070 * <del>æœ??に呼ばれたときに、作æ?しã?以降ã?、そのコネクションを返しますã?</del>
071 * 呼ばれる都度、新しい Connection を返しますã?ただしã?Connection 自身はã€?
072 * ConnectionFactory から取得するためã?基本çš?�«はキャãƒ?‚·ュされたConnectionですã?
073 *
074 * @og.rev 5.3.7.0 (2011/07/01) dbidチェãƒ?‚¯
075 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソãƒ?ƒ‰を呼ぶ為、å»?¢
076 *
077 * @param dbid 接続å?ID (こã?クラスでは無視されまã�?
078 *
079 * @return æŒ?®šã?DBID に対応したã?Connection オブジェクãƒ?
080 */
081 // public Connection getConnection( final String dbid ) {
082 // if( conn != null ) { close(); }
083 //
084 // this.dbid = dbid;
085 // this.conn = ConnectionFactory.connection( dbid,appInfo );
086 // return conn ;
087 // }
088
089 /**
090 * コミットå?ç�?‚’行いますã?
091 *
092 * これは、呼ばれる都度、リアルタイãƒ?�«処ç�?�—ますã?
093 *
094 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソãƒ?ƒ‰を呼ぶ為、å»?¢
095 *
096 * @return 正常:true/異常:false
097 */
098 // public boolean commit() {
099 // return Closer.commit( conn );
100 // }
101
102 /**
103 * ロールバック処ç�?‚’行いますã?
104 *
105 * これは、呼ばれる都度、リアルタイãƒ?�«処ç�?�—ますã?
106 *
107 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソãƒ?ƒ‰を呼ぶ為、å»?¢
108 *
109 * @return 正常:true/異常:false
110 */
111 // public boolean rollback() {
112 // return Closer.rollback( conn );
113 // }
114
115 /**
116 * トランザクションの、終äº?™‚処ç�?‚’行いますã?
117 *
118 * @og.rev 5.3.8.0 (2011/08/01) 親クラスのメソãƒ?ƒ‰を呼ぶ為、å»?¢
119 *
120 * @see #close( boolean )
121 *
122 * @return 正常:true/異常:false
123 */
124 // public boolean close() {
125 // return close( false );
126 // }
127
128 /**
129 * コネクションの、終äº?™‚処ç�?‚’行いますã?
130 *
131 * 引数は、正常かどã�?�‹を判定するフラグですã?異常の場合ã?、true をセãƒ?ƒˆしますã?
132 * これは、ConnectionFactory のプã?ルに戻すかどã�?�‹を判断するのに使われますã?
133 * ä¸?º¦でもã?エラーが発生したコネクションは、ç?æ£?�—ますã?
134 * それ以外ã?、ã?ールに戻しますã?
135 *
136 * @og.rev 5.3.7.0 (2011/07/01) close時に、コネクションã‚?null 化しておくã€?
137 * @og.rev 5.3.8.0 (2011/08/01) 終äº??ç�?‚’行い、親クラスのrealClose() を呼ぶã€?
138 *
139 * @param errFlag [true:エラー状æ…?false:通常]
140 *
141 * @return 正常:true/異常:false
142 */
143 @Override
144 public boolean close( final boolean errFlag ) {
145 // if( errFlag ) { ConnectionFactory.remove( conn,dbid ); } // 削除
146 // else { ConnectionFactory.close( conn,dbid ); } // 返却
147
148 // conn = null; // 5.3.7.0 (2011/07/01)
149 // return true;
150
151 // 5.3.8.0 (2011/08/01) 終äº??ç�?‚’行い、親クラスのrealClose() を呼ぶã€?
152 super.close( errFlag );
153 finish();
154 realClose();
155
156 return true;
157 }
158 }