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(TemporalAccessor currentDateTime)
Creates an instance of the StubScheduler that uses the given
currentDateTime as its conceptual
"current time". |
Modifier and Type | Method and Description |
---|---|
void |
advanceTimeBy(Duration duration,
EventConsumer<EventMessage<?>> eventConsumer)
Advance time by the given
duration and invokes the given eventConsumer for each
event scheduled for publication until that time. |
void |
advanceTimeTo(Instant newDateTime,
EventConsumer<EventMessage<?>> eventConsumer)
Advance time to the given
newDateTime and invokes the given eventConsumer for each
event 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.
|
Instant |
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.
|
void |
initializeAt(TemporalAccessor currentDateTime)
Resets the initial "current time" of this SubEventScheduler.
|
ScheduleToken |
schedule(Duration triggerDuration,
Object event)
Schedule the given
event for publication after the given triggerDuration . |
ScheduleToken |
schedule(Instant triggerDateTime,
Object event)
Schedule the given
event for publication at the given triggerDateTime . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reschedule, reschedule, shutdown
public StubEventScheduler()
public StubEventScheduler(TemporalAccessor currentDateTime)
currentDateTime
as its conceptual
"current time".currentDateTime
- The instant to use as current Date and Timepublic void initializeAt(TemporalAccessor currentDateTime)
currentDateTime
- The instant to use as the current Date and TimeIllegalStateException
- when calling this method after events are scheduledpublic ScheduleToken schedule(Instant 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(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 Instant getCurrentDateTime()
public EventMessage advanceToNextTrigger()
public void advanceTimeTo(Instant newDateTime, EventConsumer<EventMessage<?>> eventConsumer)
newDateTime
and invokes the given eventConsumer
for each
event scheduled for publication until that time.newDateTime
- The time to advance the "current time" of the scheduler toeventConsumer
- The function to invoke for each event to triggerpublic void advanceTimeBy(Duration duration, EventConsumer<EventMessage<?>> eventConsumer)
duration
and invokes the given eventConsumer
for each
event scheduled for publication until that time.duration
- The amount of time to advance the "current time" of the scheduler witheventConsumer
- The function to invoke for each event to triggerCopyright © 2010–2024. All rights reserved.