1 package de.webman.util.scheduler; 2 3 import java.util.Date ; 4 import org.apache.log4j.Category; 5 6 13 public abstract class ServiceEntry 14 { 15 16 19 private static Category cat = Category.getInstance(ServiceEntry.class); 20 21 24 String id = null; 25 26 29 Date start_at = null; 30 31 34 Date stop_at = null; 35 36 39 long frequency = 0; 40 41 44 long delay = 0; 45 46 49 SchedulerServiceFactory factory = null; 50 51 54 long last = 0; 55 56 64 protected void init(String _id, 65 Date _start_at, 66 Date _stop_at, 67 long _frequency, long _delay, 68 SchedulerServiceFactory _factory) 69 { 70 id = _id; 71 start_at = _start_at; 72 stop_at = _stop_at; 73 frequency = _frequency; 74 delay = _delay; 75 factory = _factory; 76 last = 0; 77 } 78 79 80 83 abstract boolean isDue(Date ref); 84 85 90 void executeNewService() { 91 execute(); 92 } 93 94 97 abstract boolean isOutdated(Date ref); 98 99 protected void execute() { 100 101 try { 102 new Thread (new ServiceThread(id, factory.newService())).start(); 103 } 104 catch (SchedulerException se) { 105 cat.error("starting scheduler exception: '" + id + "' (" + se + ")"); 106 } 107 } 108 109 } 110 | Popular Tags |