public class StubDeadlineManager extends Object implements DeadlineManager
DeadlineManager. Records all scheduled, canceled and met deadlines.| Constructor and Description |
|---|
StubDeadlineManager()
Initializes the manager with
ZonedDateTime.now() as current time. |
StubDeadlineManager(TemporalAccessor currentDateTime)
Initializes the manager with provided
currentDateTime as current time. |
| Modifier and Type | Method and Description |
|---|---|
void |
advanceTimeBy(Duration duration,
DeadlineConsumer deadlineConsumer)
Advances time by the given
duration and invokes the given deadlineConsumer for each deadline
scheduled until that time. |
void |
advanceTimeTo(Instant newDateTime,
DeadlineConsumer deadlineConsumer)
Advances time to the given
newDateTime and invokes the given deadlineConsumer for each deadline
scheduled until that time. |
ScheduledDeadlineInfo |
advanceToNextTrigger()
Advances the "current time" of the manager to the next scheduled deadline, and returns that deadline.
|
void |
cancelAll(String deadlineName)
Cancels all the deadlines corresponding to the given
deadlineName. |
void |
cancelAllWithinScope(String deadlineName,
ScopeDescriptor scope)
Cancels all deadlines corresponding to the given
deadlineName and scope. |
void |
cancelSchedule(String deadlineName,
String scheduleId)
Cancels the deadline corresponding to the given
deadlineName / scheduleId combination. |
Instant |
getCurrentDateTime()
Return the current date and time as an
Instant as is being used by this DeadlineManager. |
List<ScheduledDeadlineInfo> |
getDeadlinesMet()
Deprecated.
in favor of
getTriggeredDeadlines() |
List<ScheduledDeadlineInfo> |
getScheduledDeadlines()
Return all scheduled deadlines which have not been met (yet).
|
List<ScheduledDeadlineInfo> |
getTriggeredDeadlines()
Return all triggered deadlines.
|
void |
initializeAt(TemporalAccessor currentDateTime)
Resets the initial "current time" of this manager.
|
Registration |
registerDispatchInterceptor(MessageDispatchInterceptor<? super DeadlineMessage<?>> dispatchInterceptor)
Register the given DispatchInterceptor.
|
Registration |
registerHandlerInterceptor(MessageHandlerInterceptor<? super DeadlineMessage<?>> handlerInterceptor)
Register the given
handlerInterceptor. |
String |
schedule(Duration triggerDuration,
String deadlineName,
Object payloadOrMessage,
ScopeDescriptor deadlineScope)
Schedules a deadline after the given
triggerDuration with provided context. |
String |
schedule(Instant triggerDateTime,
String deadlineName,
Object payloadOrMessage,
ScopeDescriptor deadlineScope)
Schedules a deadline at given
triggerDateTime with provided context. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcancelAllWithinScope, schedule, schedule, schedule, schedule, shutdownpublic StubDeadlineManager()
ZonedDateTime.now() as current time.public StubDeadlineManager(TemporalAccessor currentDateTime)
currentDateTime as current time.currentDateTime - The instance to use as current date and timepublic void initializeAt(TemporalAccessor currentDateTime) throws IllegalStateException
currentDateTime - The instant to use as the current date and timeIllegalStateException - when calling this method after deadlines are scheduled@Nonnull public String schedule(@Nonnull Instant triggerDateTime, @Nonnull String deadlineName, Object payloadOrMessage, @Nonnull ScopeDescriptor deadlineScope)
DeadlineManagertriggerDateTime with provided context. The returned scheduleId and
provided deadlineName combination can be used to cancel the scheduled deadline.
The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the
instance provided is the donor for the payload and MetaData of the actual
deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a
DeadlineMessage.
schedule in interface DeadlineManagertriggerDateTime - A Instant denoting the moment to trigger the deadline handlingdeadlineName - A String representing the name of the deadline to schedulepayloadOrMessage - A Message or payload for a message as an
ObjectdeadlineScope - A ScopeDescriptor describing the scope within which the deadline was scheduledscheduleId as a String to use when cancelling the schedule@Nonnull public String schedule(@Nonnull Duration triggerDuration, @Nonnull String deadlineName, Object payloadOrMessage, @Nonnull ScopeDescriptor deadlineScope)
DeadlineManagertriggerDuration with provided context. The provided
deadlineName / scheduleId combination can be used to cancel the scheduled deadline.
The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the
instance provided is the donor for the payload and MetaData of the actual
deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a
DeadlineMessage.
schedule in interface DeadlineManagertriggerDuration - A Duration describing the waiting period before handling the deadlinedeadlineName - A String representing the name of the deadline to schedulepayloadOrMessage - A Message or payload for a message as an
ObjectdeadlineScope - A ScopeDescriptor describing the scope within which the deadline was scheduledscheduleId as a String to use when cancelling the schedulepublic void cancelSchedule(@Nonnull String deadlineName, @Nonnull String scheduleId)
DeadlineManagerdeadlineName / scheduleId combination. This
method has no impact on deadlines which have already been triggered.cancelSchedule in interface DeadlineManagerdeadlineName - a String representing the name of the deadline to cancelscheduleId - the String denoting the scheduled deadline to cancelpublic void cancelAll(@Nonnull String deadlineName)
DeadlineManagerdeadlineName. This method has no impact on deadlines
which have already been triggered.cancelAll in interface DeadlineManagerdeadlineName - a String representing the name of the deadlines to cancelpublic void cancelAllWithinScope(@Nonnull String deadlineName, @Nonnull ScopeDescriptor scope)
DeadlineManagerdeadlineName and scope.
This method has no impact on deadlines which have already been triggered.cancelAllWithinScope in interface DeadlineManagerdeadlineName - a String representing the name of the deadlines to cancelscope - a ScopeDescriptor describing the scope within which the deadline was scheduledpublic List<ScheduledDeadlineInfo> getScheduledDeadlines()
@Deprecated public List<ScheduledDeadlineInfo> getDeadlinesMet()
getTriggeredDeadlines()public List<ScheduledDeadlineInfo> getTriggeredDeadlines()
public Instant getCurrentDateTime()
Instant as is being used by this DeadlineManager.public ScheduledDeadlineInfo advanceToNextTrigger()
ScheduledDeadlineInfo of the first scheduled deadlinepublic void advanceTimeTo(Instant newDateTime, DeadlineConsumer deadlineConsumer)
newDateTime and invokes the given deadlineConsumer for each deadline
scheduled until that time.newDateTime - the time to advance the "current time" of the manager todeadlineConsumer - the consumer to invoke for each deadline to triggerpublic void advanceTimeBy(Duration duration, DeadlineConsumer deadlineConsumer)
duration and invokes the given deadlineConsumer for each deadline
scheduled until that time.duration - the amount of time to advance the "current time" of the manager withdeadlineConsumer - the consumer to invoke for each deadline to trigger@Nonnull public Registration registerDispatchInterceptor(@Nonnull MessageDispatchInterceptor<? super DeadlineMessage<?>> dispatchInterceptor)
MessageDispatchInterceptorSupportregisterDispatchInterceptor in interface MessageDispatchInterceptorSupport<DeadlineMessage<?>>dispatchInterceptor - The interceptor to register@Nonnull public Registration registerHandlerInterceptor(@Nonnull MessageHandlerInterceptor<? super DeadlineMessage<?>> handlerInterceptor)
MessageHandlerInterceptorSupporthandlerInterceptor. After registration, the interceptor will be invoked for each
handled Message on the messaging component that it was registered to, prior to invoking the message's handler.registerHandlerInterceptor in interface MessageHandlerInterceptorSupport<DeadlineMessage<?>>handlerInterceptor - The interceptor to registerCopyright © 2010–2023. All rights reserved.