KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > email > EmailBackgroundHandler


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.applications.email;
12
13
14 import org.mmbase.module.core.*;
15
16 import org.mmbase.util.logging.Logging;
17 import org.mmbase.util.logging.Logger;
18
19 /**
20  *
21  * background hanlder for sending email, a call backthread
22  * that is used to send email (one thread per active email
23  * node)
24  * @author Daniel Ockeloen
25  */

26 public class EmailBackgroundHandler implements Runnable JavaDoc {
27
28     static private final Logger log = Logging.getLoggerInstance(EmailBackgroundHandler.class);
29
30     // email node
31
private MMObjectNode node;
32
33
34     /**
35      * create a background thread with given email node
36      */

37     public EmailBackgroundHandler(MMObjectNode node) {
38         this.node = node;
39         Thread JavaDoc kicker = new Thread JavaDoc(this, "emailbackgroundhandler");
40         //kicker.setDaemon(false); // mail should be sent before jvm can end
41
kicker.start();
42     }
43
44     
45     /**
46      * Main run, exception protected
47      */

48     public void run () {
49     // now we run in a new thread call
50
// the email handler to start sending the node
51
try {
52             EmailHandler.sendMailNode(node);
53         } catch(Exception JavaDoc e) {
54             log.error("run(): ERROR: Exception in emailbackgroundhandler thread!");
55             log.error(Logging.stackTrace(e));
56         }
57     }
58
59 }
60
Popular Tags