001package org.opengion.fukurou.business;
002
003import org.opengion.fukurou.db.TransactionImpl;
004import org.opengion.fukurou.util.HybsLoader;
005import org.opengion.fukurou.util.HybsLoaderConfig;
006import org.opengion.fukurou.util.HybsLoaderFactory;
007
008/**
009 * bizLogicファイル共通クラス
010 * bizLogicファイルを処理するための、
011 * 共通クラスです。
012 *
013 * @og.rev 5.10.15.2 (2019/09/20) 新規作成
014 * 
015 * @version 5
016 * @author oota
017 * @since JDK7
018 */
019public class BizUtil {
020        
021        /**
022         * private コンスタクター
023         * インスタンスは生成せずに、利用します。
024         */
025        private BizUtil() {     }
026        
027        /**
028         * bizLogicファイルの実行 bizLogicファイルをホットデプロイして、
029         * 処理を実行します。
030         * 
031         * @param srcDir ソースディレクトリ
032         * @param classDir クラスディレクトリ
033         * @param isAutoCompile オートコンプリートフラグ
034         * @param isHotDeploy ホットデプロイフラグ
035         * @param classPath クラスパス
036         * @param systemId システムID
037         * @param logicName ロジック名
038         * @param keys キーリスト
039         * @param vals 値リスト
040         * @throws エラー情報
041         */
042        public static void actBizLogic(final String srcDir, final String classDir, final boolean isAutoCompile, final boolean isHotDeploy, final String classPath,
043                        final String systemId, final String logicName, final String[] keys, final String[] vals) throws Throwable {
044
045                // bizクラスファイルのホットデプロイ
046                HybsLoader ldr = HybsLoaderFactory
047                                .getLoader(new HybsLoaderConfig(srcDir, classDir, isAutoCompile, isHotDeploy, classPath));
048
049                BizLogicHelper helper = new BizLogicHelper(logicName, ldr);
050
051                TransactionImpl tran = new TransactionImpl(null);
052                helper.setTransaction(tran);
053                helper.setDbid(systemId);
054                helper.setKeys(keys);
055                helper.setVals(vals);
056
057                try {
058                        // bizLogic実行
059                        helper.exec();
060                        
061                        // 正常に実行された場合
062                        tran.commit();
063                        tran.finish();
064                }catch(Throwable e) {
065                        // エラー発生時
066                        tran.rollback();
067                        throw  e;
068                } finally {
069                        if (tran != null) {
070                                tran.close();
071                                tran.realClose();
072                        }
073                }
074        }
075}