1 14 package org.jmanage.core.alert.delivery; 15 16 import org.jmanage.core.util.CoreUtils; 17 import org.jmanage.core.alert.AlertInfo; 18 19 import java.io.File ; 20 21 29 public class EmailAlerts extends PersistedAlerts{ 30 31 private static final String EMAIL_ALERTS_FILE = 32 CoreUtils.getDataDir() + File.separator + "email-alerts.xml"; 33 34 private static final EmailAlerts instance = new EmailAlerts(); 35 36 public static EmailAlerts getInstance(){ 37 return instance; 38 } 39 40 private EmailAlerts(){ 41 new EmailDeliveryThread().start(); 42 } 43 44 protected String getPersistedFileName() { 45 return EMAIL_ALERTS_FILE; 46 } 47 48 private class EmailDeliveryThread extends Thread { 49 50 EmailDelivery delivery = new EmailDelivery(); 51 52 public void run(){ 53 while(true){ 54 AlertInfo alertInfo = EmailAlerts.this.remove(); 55 if(alertInfo != null){ 56 delivery.deliver(alertInfo); 59 } 60 try { 61 62 sleep(60*1000); 63 } catch (InterruptedException e) { 64 } 65 } 66 } 67 } 68 } 69 | Popular Tags |