01: package de.webman.util.scheduler;
02:
03: import java.util.Date;
04: import java.util.Calendar;
05:
06: /**
07: * this service entry represents a service which is called once only at a
08: * given point in time. The service is deregistered after execution.
09: *
10: * @author <a href="mailto:gregor@webman.de">Gregor Klinke</a>
11: * @version $Revision: 1.2 $
12: **/
13: class OneTimeService extends ServiceEntry {
14: /* $Id: OneTimeService.java,v 1.2 2002/04/12 12:45:53 gregor Exp $ */
15:
16: /**
17: * if this service has been executed
18: **/
19: private boolean executed = false;
20:
21: /**
22: * constructor, only to be used by the schedule manager
23: * @param _id the identification string of the service
24: * @param _start_at start the service at this point, must not be
25: * <code>null</code>
26: * @param _factory an instance of the service to execute
27: **/
28: OneTimeService(String _id, Date _start_at,
29: SchedulerServiceFactory _factory) {
30: init(_id, _start_at, null, 0, 0, _factory);
31: }
32:
33: /**
34: * returns <code>true</code> if the service is due to be executed
35: * @param ref the reference date to check for
36: * @return <code>true</code> if it is due
37: **/
38: boolean isDue(Date ref) {
39: return ref.after(start_at);
40: }
41:
42: /**
43: * returns <code>true</code> if this service is outdated
44: * @param ref the reference date to check for
45: * @return <code>true</code> if it is outdated
46: **/
47: boolean isOutdated(Date ref) {
48: return executed;
49: }
50:
51: /**
52: * starts a service, by allocating a new service instance and starting
53: * it of in a new thread ({@link
54: * de.webman.util.scheduler.ServiceThread})
55: **/
56: void executeNewService() {
57: execute();
58: executed = true;
59: }
60:
61: }
|