1 package example; 2 3 import java.util.TimerTask ; 4 5 import java.util.logging.Logger ; 6 import java.util.logging.Level ; 7 8 import javax.resource.spi.work.Work ; 9 import javax.resource.spi.work.WorkManager ; 10 import javax.resource.spi.work.WorkException ; 11 12 15 public class WorkScheduleTimerTask extends TimerTask { 16 private static final Logger log = 17 Logger.getLogger(TimerTask .class.getName()); 18 19 private WorkManager _workManager; 20 private Work _work; 21 22 25 WorkScheduleTimerTask(WorkManager workManager, Work work) 26 { 27 _workManager = workManager; 28 _work = work; 29 } 30 31 34 public void run() 35 { 36 log.fine("timer starting"); 37 38 try { 39 _workManager.scheduleWork(_work); 40 } catch (WorkException e) { 41 log.log(Level.WARNING, e.toString(), e); 42 } 43 } 44 } 45 | Popular Tags |