Java tutorial
/** * PureInfo Command * @(#)SRMMailEngine.java 1.0 2007-1-17 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.srm.sender.engines; import java.util.Timer; import java.util.TimerTask; import org.apache.commons.lang.time.DateUtils; import org.apache.log4j.Logger; import com.pureinfo.force.exception.PureException; import com.pureinfo.force.runtime.engine.EngineBase; import com.pureinfo.srm.sender.SRMMailMachine; /** * * <P> * Created on 2007-1-17 10:01:18<BR> * Last modified on 2007-1-17 * </P> * SRMMailEngine * * @author sunjie * @version 1.0, 2007-1-17 * @since Command 1.0 */ public class SRMMailEngine extends EngineBase { private static final Logger logger = Logger.getLogger(SRMMailEngine.class); private Timer m_timer = new Timer(); /** */ private final long DELAY = DateUtils.MILLIS_PER_SECOND * 10; /** */ private final long PERIOD = DateUtils.MILLIS_PER_SECOND * 300; protected void doStartup() throws PureException { if (logger.isInfoEnabled()) { logger.info("mail engine startup."); } m_timer = new Timer(); m_timer.schedule(new TimerTask() { public void run() { try { SRMMailMachine machine = new SRMMailMachine(); machine.send(); } catch (Exception e) { logger.warn("mail engine error,", e); } } }, DELAY, PERIOD); } protected void doShutdown() throws PureException { if (m_timer != null) { m_timer.cancel(); m_timer = null; } } //public static void main(String[] args) throws PureException { // new SRMMailEngine().startup(); //} }