public class StubEventScheduler extends Object implements EventScheduler
Constructor and Description |
---|
StubEventScheduler()
Creates an instance of the StubScheduler that uses the current date time as its conceptual "current time".
|
StubEventScheduler(org.joda.time.ReadableInstant currentDateTime)
Creates an instance of the StubScheduler that uses the given
currentDateTime as its conceptual
"current time". |
Modifier and Type | Method and Description |
---|---|
List<EventMessage> |
advanceTime(org.joda.time.DateTime newDateTime)
Advance time to the given
newDateTime and returns all events scheduled for publication until that
time. |
List<EventMessage> |
advanceTime(org.joda.time.Duration duration)
Advance time by the given
duration and returns all events scheduled for publication until that
time. |
EventMessage |
advanceToNextTrigger()
Advances the "current time" of the scheduler to the next scheduled Event, and returns that event.
|
void |
cancelSchedule(ScheduleToken scheduleToken)
Cancel the publication of a scheduled event.
|
org.joda.time.DateTime |
getCurrentDateTime()
Returns the "Current Date Time" as used by the scheduler.
|
List<ScheduledItem> |
getScheduledItems()
Returns a view of all the scheduled Events at the time this method is called.
|
ScheduleToken |
schedule(org.joda.time.DateTime triggerDateTime,
Object event)
Schedule the given
event for publication at the given triggerDateTime . |
ScheduleToken |
schedule(org.joda.time.Duration triggerDuration,
Object event)
Schedule the given
event for publication after the given triggerDuration . |
public StubEventScheduler()
public StubEventScheduler(org.joda.time.ReadableInstant currentDateTime)
currentDateTime
as its conceptual
"current time".currentDateTime
- The instant to use as current Date and Timepublic ScheduleToken schedule(org.joda.time.DateTime triggerDateTime, Object event)
EventScheduler
event
for publication at the given triggerDateTime
. The returned
ScheduleToken can be used to cancel the planned publication.
The given event
may be any object, as well as an EventMessage. In the latter case, the instance
provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case,
the given event
will be wrapped as the payload of an EventMessage.schedule
in interface EventScheduler
triggerDateTime
- The moment to trigger publication of the eventevent
- The event to publishpublic ScheduleToken schedule(org.joda.time.Duration triggerDuration, Object event)
EventScheduler
event
for publication after the given triggerDuration
. The
returned ScheduleToken can be used to cancel the planned publication.
The given event
may be any object, as well as an EventMessage. In the latter case, the instance
provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case,
the given event
will be wrapped as the payload of an EventMessage.schedule
in interface EventScheduler
triggerDuration
- The amount of time to wait before publishing the eventevent
- The event to publishpublic void cancelSchedule(ScheduleToken scheduleToken)
EventScheduler
cancelSchedule
in interface EventScheduler
scheduleToken
- the token returned when the event was scheduledpublic List<ScheduledItem> getScheduledItems()
public org.joda.time.DateTime getCurrentDateTime()
public EventMessage advanceToNextTrigger()
public List<EventMessage> advanceTime(org.joda.time.DateTime newDateTime)
newDateTime
and returns all events scheduled for publication until that
time.newDateTime
- The time to advance the "current time" of the scheduler topublic List<EventMessage> advanceTime(org.joda.time.Duration duration)
duration
and returns all events scheduled for publication until that
time.duration
- The amount of time to advance the "current time" of the scheduler withCopyright © 2010-2014. All Rights Reserved.