KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > WorkScheduleTimerTask


1 package example;
2
3 import java.util.TimerTask JavaDoc;
4
5 import java.util.logging.Logger JavaDoc;
6 import java.util.logging.Level JavaDoc;
7
8 import javax.resource.spi.work.Work JavaDoc;
9 import javax.resource.spi.work.WorkManager JavaDoc;
10 import javax.resource.spi.work.WorkException JavaDoc;
11
12 /**
13  * Implements the timer task. This task just launches the work task.
14  */

15 public class WorkScheduleTimerTask extends TimerTask JavaDoc {
16   private static final Logger JavaDoc log =
17     Logger.getLogger(TimerTask JavaDoc.class.getName());
18
19   private WorkManager JavaDoc _workManager;
20   private Work JavaDoc _work;
21
22   /**
23    * Creates the timer task.
24    */

25   WorkScheduleTimerTask(WorkManager JavaDoc workManager, Work JavaDoc work)
26   {
27     _workManager = workManager;
28     _work = work;
29   }
30
31   /**
32    * The method called to execute the task, like Runnable
33    */

34   public void run()
35   {
36     log.fine("timer starting");
37
38     try {
39       _workManager.scheduleWork(_work);
40     } catch (WorkException JavaDoc e) {
41       log.log(Level.WARNING, e.toString(), e);
42     }
43   }
44 }
45
Popular Tags