com.sun.sgs.impl.kernel.schedule
Class RecurringTaskHandleImpl

java.lang.Object
  extended by com.sun.sgs.impl.kernel.schedule.RecurringTaskHandleImpl
All Implemented Interfaces:
RecurringTaskHandle

 class RecurringTaskHandleImpl
extends Object
implements RecurringTaskHandle

Simple implementation of RecurringTaskHandle that lets the handle be associated with a TimerTask so that cancelling the handle also cancels the associated TimerTask.


Constructor Summary
RecurringTaskHandleImpl(SchedulerQueue queue, ScheduledTask task)
          Creates an instance of RecurringTaskHandleImpl.
 
Method Summary
 void cancel()
          Cancels this handle, which will also cancel the associated TimerTask and notify the SchedulerQueue about the task being cancelled.
(package private)  boolean isCancelled()
          Returns whether this handle has been cancelled.
(package private)  void setTimerTask(TimerTask timerTask)
          Sets the associated TimerTask for this handle.
 void start()
          Starts the associated task running by passing the task to the SchedulerQueue via a call to addTask.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecurringTaskHandleImpl

public RecurringTaskHandleImpl(SchedulerQueue queue,
                               ScheduledTask task)
Creates an instance of RecurringTaskHandleImpl.

Parameters:
queue - the SchedulerQueue that is using this handle
task - the task for this handle
Throws:
IllegalArgumentException - if the task is not recurring
Method Detail

setTimerTask

void setTimerTask(TimerTask timerTask)
Sets the associated TimerTask for this handle. This method may be called any number of times on a handle. Typically a recurring task will re-set the associated TimerTask with each recurrence of execution.

Parameters:
timerTask - the associated TimerTask

isCancelled

boolean isCancelled()
Returns whether this handle has been cancelled. This does not say anything about the state of any associated TimerTask.

Returns:
true if this handle has been cancelled, false otherwise

cancel

public void cancel()
Cancels this handle, which will also cancel the associated TimerTask and notify the SchedulerQueue about the task being cancelled. If this handle has already been cancelled, then an exception is thrown.

Specified by:
cancel in interface RecurringTaskHandle
Throws:
IllegalStateException - if this handle has already been cancelled

start

public void start()
Starts the associated task running by passing the task to the SchedulerQueue via a call to addTask. If this handle has already been started or cancelled, then an exception is thrown.

Specified by:
start in interface RecurringTaskHandle
Throws:
IllegalStateException - if the handle has already been started or cancelled

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved