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 java.sql.Connection; 019 020 /** 021 * コネクションを?有して、トランザクションを実現するインターフェースです? 022 * 023 * 基本?は、TransactionTag で利用されますが、?、このオブジェクトを 024 * 渡して、直接、利用するケースもあります? 025 * 026 * トランザクション の実クラスには、リアルタイ? commit,rollback を行う? 027 * TransactionReal クラスと、?部にキャ?ュされ?コネクションを?終?点で 028 * ?処?行う、TransactionImpl があります? 029 * TransactionTag で利用するのが?TransactionImpl で、トランザクション処?行わな? 030 * ケースで利用するのが?TransactionReal クラスになります? 031 * TransactionReal クラス は、トランザクション処??行わな?場合に、?通ロジ?? 032 * 提供するために用意されたクラスです? 033 * 034 * @og.rev 5.1.9.0 (2010/08/01) 新規作? 035 * 036 * @version 5.0 037 * @author Kazuhiko Hasegawa 038 * @since JDK6.0, 039 */ 040 public interface Transaction { 041 042 /** 043 * ??DBID に対応した?Connection オブジェクトを返します? 044 * ?Mapに存在して?ば、そのコネクションを?存在しなければ? 045 * 新しく作?します? 046 * 047 * @param dbid 接続?ID 048 * 049 * @return ??DBID に対応した?コネクションオブジェク? 050 */ 051 Connection getConnection( final String dbid ) ; 052 053 /** 054 * コミット??行われた場合に、?部フラグ(isCommit)?true にセ?します? 055 * ?回でもコミットが行われており、ロールバックが行われて?ければ? 056 * コミットされます? 057 * 058 * 検索処??みで、エラーが発生して???合?、コミットも行われな?ースがあります? 059 * 060 * @return 正常:true/異常:false 061 */ 062 boolean commit() ; 063 064 /** 065 * ロールバック処?行われた場合に、?部フラグ(isRollback)?true にセ?します? 066 * ?回でもロールバックが行われて?ば、最終的にはロールバックされます? 067 * 068 * @return 正常:true/異常:false 069 */ 070 boolean rollback() ; 071 072 /** 073 * トランザクションの、終?処?行います? 074 * 075 * それまでの処??、すべて正常に処?きた場合に、使用します? 076 * close( false ) と同じです? 077 * 078 * @see #close( boolean ) 079 * 080 * @return 正常:true/異常:false 081 */ 082 boolean close() ; 083 084 /** 085 * トランザクションの、終?処?行います? 086 * 087 * 引数は、正常かど?を判定するフラグです?異常の場合?、true をセ?します? 088 * ここでは、実際には何もしませんが???エラーフラグをセ?します? 089 * (エラーの場合?みセ?。リセ?はされません) 090 * ?でも?エラーが発生したコネクションは、??ます?それ以外?、?ールに戻します? 091 * 092 * @param errFlag エラー状?[true:/false:通常] 093 * 094 * @return 正常:true/異常:false 095 */ 096 boolean close( final boolean errFlag ) ; 097 }