01: /*
02: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/common/WatchSendTask.java,v 1.4 2007/10/09 11:09:16 lexuanttkhtn Exp $
03: * $Author: lexuanttkhtn $
04: * $Revision: 1.4 $
05: * $Date: 2007/10/09 11:09:16 $
06: *
07: * ====================================================================
08: *
09: * Copyright (C) 2002-2007 by MyVietnam.net
10: *
11: * All copyright notices regarding mvnForum MUST remain
12: * intact in the scripts and in the outputted HTML.
13: * The "powered by" text/logo with a link back to
14: * http://www.mvnForum.com and http://www.MyVietnam.net in
15: * the footer of the pages MUST remain visible when the pages
16: * are viewed on the internet or intranet.
17: *
18: * This program is free software; you can redistribute it and/or modify
19: * it under the terms of the GNU General Public License as published by
20: * the Free Software Foundation; either version 2 of the License, or
21: * any later version.
22: *
23: * This program is distributed in the hope that it will be useful,
24: * but WITHOUT ANY WARRANTY; without even the implied warranty of
25: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26: * GNU General Public License for more details.
27: *
28: * You should have received a copy of the GNU General Public License
29: * along with this program; if not, write to the Free Software
30: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31: *
32: * Support can be obtained from support forums at:
33: * http://www.mvnForum.com/mvnforum/index
34: *
35: * Correspondence and Marketing Questions can be sent to:
36: * info at MyVietnam net
37: *
38: * @author: Minh Nguyen
39: * @author: Mai Nguyen
40: */
41: package com.mvnforum.common;
42:
43: import org.apache.commons.logging.Log;
44: import org.apache.commons.logging.LogFactory;
45:
46: import com.mvnforum.user.WatchWebHandler;
47:
48: import net.myvietnam.mvncore.util.TimerTaskAbstract;
49:
50: public class WatchSendTask extends TimerTaskAbstract {
51:
52: // static variable
53: private static Log log = LogFactory.getLog(WatchSendTask.class);
54:
55: // static variable
56: private static WatchSendTask instance = null;
57:
58: // instance variables
59: private int count = 0;
60: private WatchWebHandler watchWebHandler = new WatchWebHandler();
61:
62: // private constructor will prevent any instatiation
63: private WatchSendTask() {
64: }
65:
66: /**
67: * This static method is used to get the Singleton instance of WatchTask
68: * @return the singleton instance of WatchTask
69: */
70: public static synchronized WatchSendTask getInstance() {
71: if (instance == null) {
72: instance = new WatchSendTask();
73: }
74: return instance;
75: }
76:
77: public void run() {
78: count++;
79: long start = System.currentTimeMillis();
80: try {
81: log.debug("Begin sendMail in WatchSendTask");
82: watchWebHandler.sendMail();
83: } catch (Throwable ex) {
84: log.error("Cannot process sendMail in WatchSendTask", ex);
85: } finally {
86: long duration = System.currentTimeMillis() - start;
87: log.info("WatchSendTask:sendMail process " + count
88: + " times, took " + duration + " ms");
89: }
90: }
91: }
|