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 020 import org.opengion.fukurou.util.HybsTimerTask; 021 import org.opengion.fukurou.util.LogWriter; 022 023 import org.opengion.hayabusa.mail.MailManager_DB; 024 025 /** 026 * メールパラメータ??ブルを監視して、メール送信プログラ?呼び出します? 027 * こ?クラスは、HybsTimerTask を継承した タイマ?タスククラスです? 028 * startDaemon() がタイマ?タスクによって、呼び出されます? 029 * 030 * @og.group メールモジュール 031 * 032 * @version 4.0 033 * @author Sen.Li 034 * @since JDK1.6 035 */ 036 public class MailDaemon extends HybsTimerTask { 037 038 private int loopCnt = 0; 039 040 private static final int LOOP_COUNTER = 24; // カウンタ?4回に設? 041 042 /** 043 * こ?タイマ?タスクによって初期化されるアクションです? 044 * パラメータを使用した初期化を行います? 045 * 046 */ 047 @Override 048 public void initDaemon() { 049 // 何もありません?PMD エラー回避) 050 } 051 052 /** 053 * タイマ?タスクの??モン処??開始?イントです? 054 * 055 */ 056 @Override 057 protected void startDaemon() { 058 if( loopCnt % LOOP_COUNTER == 0 ) { 059 loopCnt = 1; 060 System.out.println( toString() + " " + new Date() + " " ); 061 } 062 else { 063 String systemId = null; 064 try { 065 systemId = getValue( "SYSTEM_ID" ); 066 MailManager_DB manager = new MailManager_DB(); 067 manager.sendDBMail( systemId ); 068 } 069 catch( RuntimeException rex ) { 070 String errMsg = "メール送信失敗しました? 071 + " SYSTEM_ID=" + systemId ; // 5.1.8.0 (2010/07/01) errMsg 修正 072 LogWriter.log( errMsg ); 073 } 074 loopCnt++ ; 075 } 076 } 077 }