net.esper.schedule
Interface SchedulingService

All Known Implementing Classes:
SchedulingServiceImpl

public interface SchedulingService

Interface for a service that allows to add and remove callbacks for a certain time which are called when the evaluate method is invoked and the current time is on or after the callback times. It is the expectation that the triggerPast method is called with same or ascending values for each subsequent call. Callbacks with are triggered are automatically removed by implementations.


Method Summary
 void add(long afterMSec, ScheduleCallback callback)
          Add a callback for after the given milliseconds from the current time.
 void add(ScheduleSpec scheduleSpec, ScheduleCallback callback)
          Add a callback for a time specified by the schedule specification passed in based on the current time.
 void evaluate()
          Evaluate the current time and perform any callbacks.
 long getTime()
          Gets the last time known to the scheduling service.
 void remove(ScheduleCallback callback)
          Remove a callback.
 void setTime(long timestamp)
          Set the time based upon which the evaluation of events invokes callbacks.
 

Method Detail

add

void add(long afterMSec,
         ScheduleCallback callback)
         throws ScheduleServiceException
Add a callback for after the given milliseconds from the current time. If the same callback (equals) was already added before, the method will not add a new callback or change the existing callback to a new time, but throw an exception.

Parameters:
afterMSec - number of millisec to get a callback
callback - to add
Throws:
ScheduleServiceException - thrown if the add operation did not complete

add

void add(ScheduleSpec scheduleSpec,
         ScheduleCallback callback)
         throws ScheduleServiceException
Add a callback for a time specified by the schedule specification passed in based on the current time. If the same callback (equals) was already added before, the method will not add a new callback or change the existing callback to a new time, but throw an exception.

Parameters:
scheduleSpec - holds the crontab-like information defining the next occurance
callback - to add
Throws:
ScheduleServiceException - thrown if the add operation did not complete

remove

void remove(ScheduleCallback callback)
            throws ScheduleServiceException
Remove a callback. If the callback to be removed was not found an exception is thrown.

Parameters:
callback - to remove
Throws:
ScheduleServiceException - thrown if the callback was not located

getTime

long getTime()
Gets the last time known to the scheduling service.

Returns:
time that has last been set on this service

setTime

void setTime(long timestamp)
Set the time based upon which the evaluation of events invokes callbacks.

Parameters:
timestamp - to set

evaluate

void evaluate()
Evaluate the current time and perform any callbacks.