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.plugin.daemon;
017    
018    import java.util.Date;
019    import java.util.concurrent.atomic.AtomicBoolean;       // 5.5.2.6 (2012/05/25) findbugs対?
020    
021    import org.opengion.fukurou.util.HybsTimerTask;
022    import org.opengion.fukurou.util.StringUtil;
023    import org.opengion.hayabusa.report2.ExecThreadManager;
024    import org.opengion.hayabusa.report2.QueueManager_DB;
025    
026    /**
027     * 【レポ?ト?力?帳票要求テーブルを監視して、帳票処??ログラ?呼び出します?
028     * こ?クラスは、HybsTimerTask を継承した タイマ?タスククラスです?
029     * startDaemon() がタイマ?タスクによって、呼び出されます?
030     *
031     * @og.rev 4.3.4.4 (2009/01/01) プラグイン?
032     * @og.group ??モン
033     *
034     * @version  4.0
035     * @author   Hiroki.Nakamura
036     * @since    JDK1.6
037     */
038    public class Daemon_Report2 extends HybsTimerTask {
039            //* こ?プログラ??VERSION??を設定します?       {@value} */
040            private static final String VERSION = "5.5.2.6 (2012/05/25)" ;
041    
042            private int loopCnt = 0;
043    
044            private static final int LOOP_COUNTER = 24; // カウンタ?4回に設?
045    //      private static boolean DEBUG = false;
046    //      private static boolean debug = false;           // 4.3.1.1 (2008/08/23) 変数は小文字へ
047            private static AtomicBoolean debug = new AtomicBoolean( false );                // 5.5.2.6 (2012/05/25) findbugs対?
048    
049            /**
050             * こ?タイマ?タスクによって初期化されるアクションです?
051             * パラメータを使用した初期化を行います?
052             *
053             * @og.rev 5.5.2.6 (2012/05/25) findbugs対応?staticフィールドへの書き込みに、AtomicInteger を利用します?
054             */
055            @Override
056            public void initDaemon() {
057    //              DEBUG = StringUtil.nval( getValue( "DEBUG" ),DEBUG ) ;
058    //              ExecThreadManager.setDebug( DEBUG ); // 4.3.0.0 (2008/04/15) ??処??追?
059    //              debug = StringUtil.nval( getValue( "DEBUG" ),debug ) ;
060    //              ExecThreadManager.setDebug( debug ); // 4.3.0.0 (2008/04/15) ??処??追?
061    
062                    boolean flag = StringUtil.nval( getValue( "DEBUG" ),debug.get() );
063                    ExecThreadManager.setDebug( flag ); // 4.3.0.0 (2008/04/15) ??処??追?
064                    debug.set( flag );
065            }
066    
067            /**
068             * タイマ?タスクの??モン処??開始?イントです?
069             *
070             */
071            @Override
072            protected void startDaemon() {
073                    if( loopCnt % LOOP_COUNTER == 0 ) {
074                            loopCnt = 1;
075    //                      System.out.println();
076                            System.out.println( toString() + " " + new Date()  + " " );
077                    }
078                    else {
079    //                      System.out.print( "." );
080                            loopCnt++ ;
081                    }
082    
083                    QueueManager_DB.getInstance().create();
084            }
085    
086            /**
087             * こ?タイマ?タスクのcancel() メソ?をオーバ?ライドします?
088             * HybsTimerTaskManager#cancelTask( int ) を実行します?
089             *
090             * @og.rev 4.3.1.1 (2008/08/23) super.cancel() のみ実行なら?オーバ?ライド???な?
091             *
092             * @see java.util.TimerTask#cancel()
093             */
094    //      public boolean cancel() {
095    //              return super.cancel();
096    //      }
097    }