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    }