org.indi.reactor
Class SimpleTimer

java.lang.Object
  extended by org.indi.reactor.TimerHandler
      extended by org.indi.reactor.SimpleTimer
All Implemented Interfaces:
java.lang.Comparable<TimerHandler>, TimerCallback

public class SimpleTimer
extends TimerHandler

A simplifyed version of the TimerHandler class taking a given delay in miliseconds instead of an expiration Date and a class implementing TimerCallback interface to be called back after the given delay.

Author:
dirk

Constructor Summary
SimpleTimer(TimerCallback callback, long timeout)
          Class constructor
 
Method Summary
 void onTimer()
          Called by the reactor when the delay has passed.
static java.util.Date shift(java.util.Date date, long mills)
          Shift a given Date object by a certain number of miliseconds
 
Methods inherited from class org.indi.reactor.TimerHandler
compareTo, equals, getExpirationDate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTimer

public SimpleTimer(TimerCallback callback,
                   long timeout)
Class constructor

Parameters:
callback - the object containing the callback method to be called after the given delay
timeout - the delay to wait before calling the callback method in milliseconds.
Method Detail

shift

public static java.util.Date shift(java.util.Date date,
                                   long mills)
Shift a given Date object by a certain number of miliseconds

Parameters:
date - the date object to be shifted
mills - the number of milliseconds to shift the timout by
Returns:
the shifted Date.

onTimer

public void onTimer()
Called by the reactor when the delay has passed. Implemented such that the onTimer method of the TimerCallback passed to the constuctor is called.

Specified by:
onTimer in interface TimerCallback
Overrides:
onTimer in class TimerHandler


Copyright © 2008. All Rights Reserved.