ch.ethz.iks.util
Class Scheduler

java.lang.Object
  extended by ch.ethz.iks.util.Scheduler

public final class Scheduler
extends java.lang.Object

Scheduler utility. Objects can be scheduled and the registered listener is called when the scheduled object becomes due. Notice: this class is going to be removed once R-OSGi moves to CDC/Foundation 1.1 and the java.util.Timer class can be used instead.

Since:
0.6
Author:
Jan S. Rellermeyer, ETH Zurich.

Constructor Summary
Scheduler(ScheduleListener listener)
          create a new scheduler.
 
Method Summary
 boolean isScheduled(java.lang.Object object)
          check, if an object is already scheduled.
 void reschedule(java.lang.Object object, long newTimestamp)
          reschedule an object for a new timestamp.
 void schedule(java.lang.Object object, long timestamp)
          schedule an object.
 void start()
          start the scheduler.
 void stop()
          stop the scheduler.
 void unschedule(java.lang.Object object)
          unschedule an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scheduler

public Scheduler(ScheduleListener listener)
create a new scheduler.

Parameters:
listener - the listener that is called whenever a scheduled object has become due.
Method Detail

start

public void start()
start the scheduler.


stop

public void stop()
stop the scheduler.


isScheduled

public boolean isScheduled(java.lang.Object object)
check, if an object is already scheduled.

Parameters:
object - the object to check.
Returns:
true, if the object is already scheduled.

schedule

public void schedule(java.lang.Object object,
                     long timestamp)
              throws java.lang.IllegalStateException
schedule an object.

Parameters:
object - the object.
timestamp - the timestamp.
Throws:
java.lang.IllegalStateException - if the object is already scheduled with a different timestamp.

reschedule

public void reschedule(java.lang.Object object,
                       long newTimestamp)
reschedule an object for a new timestamp.

Parameters:
object - the object.
newTimestamp - the new timestamp.

unschedule

public void unschedule(java.lang.Object object)
unschedule an object.

Parameters:
object - the object.


Copyright © 2009 IKS, ETH Zurich. All Rights Reserved.