01: package example;
02:
03: import java.util.TimerTask;
04:
05: import java.util.logging.Logger;
06: import java.util.logging.Level;
07:
08: import javax.resource.spi.work.Work;
09: import javax.resource.spi.work.WorkManager;
10: import javax.resource.spi.work.WorkException;
11:
12: /**
13: * Implements the timer task. This task just launches the work task.
14: */
15: public class WorkScheduleTimerTask extends TimerTask {
16: private static final Logger log = Logger.getLogger(TimerTask.class
17: .getName());
18:
19: private WorkManager _workManager;
20: private Work _work;
21:
22: /**
23: * Creates the timer task.
24: */
25: WorkScheduleTimerTask(WorkManager workManager, Work work) {
26: _workManager = workManager;
27: _work = work;
28: }
29:
30: /**
31: * The method called to execute the task, like Runnable
32: */
33: public void run() {
34: log.fine("timer starting");
35:
36: try {
37: _workManager.scheduleWork(_work);
38: } catch (WorkException e) {
39: log.log(Level.WARNING, e.toString(), e);
40: }
41: }
42: }
|