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.transfer;
017
018import org.opengion.fukurou.db.Transaction;
019import org.opengion.fukurou.util.ApplicationInfo;
020
021/**
022 * 伝送要求に対するの読取方法を定義するインターフェースです。
023 *
024 * 各実装クラスでは、読取処理{@link #read(TransferConfig, Transaction)}
025 * 、完了処理{@link #complete(TransferConfig, Transaction)}、エラー処理{@link #error(TransferConfig, ApplicationInfo)}を実装する必要があります。
026 * サブクラス内部で、DB関連の処理を行う場合は、引数のTransactionオブジェクトを利用して下さい。
027 * また、接続に対するCommit/Rollbackは、呼び出し元で行いますので、実行処理の中では行わないで下さい。
028 *
029 * また、HTTP経由での実行などで、読取処理とその後の完了/エラー処理でオブジェクトが同一出ない場合に、
030 * 外部から読取キーの取得及び設定を行うことができます。
031 * 具体的には、{@link #read(TransferConfig, Transaction)}を実行後、{@link #getKeys()}を呼び出しすることで
032 * 終了処理で処理対象となるキー情報を取得することができます。
033 * このキー情報を保持し、{@link #setKeys(String[])}で別オブジェクトに対してキーを設定することで、
034 * 完了処理{@link #complete(TransferConfig, Transaction)}、エラー処理{@link #error(TransferConfig, ApplicationInfo)}
035 * を呼び出しすることができます。
036 *
037 * @og.group 伝送システム
038 *
039 * @version  5.0
040 * @author   Hiroki.Nakamura
041 * @since    JDK1.6
042 */
043public interface TransferRead {
044
045        /**
046         * 読取処理を実行し、結果をテキストデータの配列として返します。
047         *
048         * @param config 伝送設定オブジェクト
049         * @param tran トランザクションオブジェクト
050         *
051         * @return 読み取りしたデータ(配列)
052         */
053        public String[] read( final TransferConfig config, final Transaction tran );
054
055        /**
056         * 更新キー(配列)を返します。
057         *
058         * @return 更新キー(配列)
059         */
060        public String[] getKeys();
061
062        /**
063         * 更新キー(配列)をセットします。
064         *
065         * @param keys 更新キー(配列)
066         */
067        public void setKeys( final String[] keys );
068
069        /**
070         * 完了処理を実行します。
071         * この処理は実行方法で定義された実行処理が正常終了した場合に呼び出しされます。
072         * 更新対象のキーについては、{@link #setKeys(String[])}で外部からセットすることもできます。
073         *
074         * @param config 伝送設定オブジェクト
075         * @param tran トランザクションオブジェクト
076         */
077        public void complete( final TransferConfig config, final Transaction tran );
078
079        /**
080         * エラー処理を実行します。
081         * この処理は実行方法で定義された実行処理が以上終了した場合に呼び出しされます。
082         * 更新対象のキーについては、{@link #setKeys(String[])}で外部からセットすることもできます。
083         *
084         * @param config 伝送設定オブジェクト
085         * @param appInfo DB接続情報
086         */
087        public void error( final TransferConfig config, final ApplicationInfo appInfo );
088}