dsto.dfc.util
Class TimerCallback

java.lang.Object
  extended by java.util.TimerTask
      extended by dsto.dfc.util.TimerCallback
All Implemented Interfaces:
Runnable

public class TimerCallback
extends TimerTask

Used to deliver an event from java.util.Timer. This can be used to shunt an event from a one thread to be re-delivered in another.

Example usage:

 public void propertyValueChanged (PropertyChangeEvent e)
 {
   Timer timer = java.util.Timers.getTimer (false);
   timer.schedule (new TimerEventCallback (this, "propertyValueChanged", e), 0);
 }
 
or (shorter and equivalently)
   TimerEventCallback.schedule (this, "propertyValueChanged", e);
 

Author:
phillipm

Constructor Summary
TimerCallback(Object target, String methodName, Object param)
          Create a new instance.
 
Method Summary
 void run()
           
static void schedule(Object target, String methodName, Object param)
          Shortcut to schedule an event in the shared non-daemon timer available from Timers.getTimer(boolean).
static void schedule(Object target, String methodName, Object param, long delayMillis)
          Shortcut to schedule an event in the shared daemon timer available from Timers.getTimer(boolean).
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimerCallback

public TimerCallback(Object target,
                     String methodName,
                     Object param)
              throws IllegalArgumentException
Create a new instance.

Parameters:
target - The target object to invoke the event on.
methodName - The name of the event handling method on target.
param - The parameter object.
Throws:
IllegalArgumentException - if method does not exist.
See Also:
schedule(Object, String, Object)
Method Detail

schedule

public static void schedule(Object target,
                            String methodName,
                            Object param)
                     throws IllegalArgumentException
Shortcut to schedule an event in the shared non-daemon timer available from Timers.getTimer(boolean).

Parameters:
target - The target object to invoke the event on.
methodName - The name of the event handling method on target.
param - The parameter object.
Throws:
IllegalArgumentException - if method does not exist.
See Also:
schedule(Object, String, Object, long)

schedule

public static void schedule(Object target,
                            String methodName,
                            Object param,
                            long delayMillis)
                     throws IllegalArgumentException
Shortcut to schedule an event in the shared daemon timer available from Timers.getTimer(boolean).

Parameters:
target - The target object to invoke the event on.
methodName - The name of the event handling method on target.
param - The parameter object.
delayMillis - Delay in milliseconds.
Throws:
IllegalArgumentException - if method does not exist.
See Also:
schedule(Object, String, Object)

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in class TimerTask


Copyright © 2008 Commonwealth of Australia