public class ScheduledAction
extends java.lang.Object
This class also has an optional attachment which can be used to pass state between the initiating class and the callback.
| Modifier and Type | Method and Description |
|---|---|
static ScheduledAction |
callback(long interval,
java.util.concurrent.TimeUnit timeUnit,
java.util.function.Function<ActionResult,ScheduledAction> callback)
|
static ScheduledAction |
error(java.lang.String statusMessage)
Create a
ScheduledAction which indicates that an unrecoverable error has occurred and the scheduler must
exit. |
static ScheduledAction |
exit(java.lang.String statusMessage)
Create a
ScheduledAction which indicates that the scheduler has reached the end of its life cycle
gracefully |
<T> T |
getAttachment()
Retrieve the optional attachment associated with this scheduled action
|
java.util.function.Function<ActionResult,ScheduledAction> |
getCallback() |
long |
getInterval(java.util.concurrent.TimeUnit timeUnit) |
java.lang.String |
getProcedure() |
java.lang.Object[] |
getProcedureParameters() |
java.lang.String |
getStatusMessage() |
ActionType |
getType() |
static ScheduledAction |
of(Action action)
Create a
ScheduledAction from a Action which is of type stop. |
static ScheduledAction |
of(Interval interval,
Action action)
|
static ScheduledAction |
procedureCall(long interval,
java.util.concurrent.TimeUnit timeUnit,
java.util.function.Function<ActionResult,ScheduledAction> callback,
java.lang.String procedure,
java.lang.Object... procedureParameters)
Create a
ScheduledAction which executes a procedure with given parameters after interval |
ScheduledAction |
setAttachment(java.lang.Object attachment)
Add an arbitrary attachment to this instance so that it can be retrieved from the
ActionResult |
ScheduledAction |
setStatusMessage(java.lang.String statusMessage)
Set the optional status message which will be reported in the statistics for a task and if this is an
ActionType.ERROR or ActionType.EXIT action then it will also be logged. |
java.lang.String |
toString() |
public static ScheduledAction of(Action action)
ScheduledAction from a Action which is of type stop.action - Base Action to get type and message fromScheduledAction derived from actionpublic static ScheduledAction of(Interval interval, Action action)
interval - To wait until performing actionaction - To be performed after intervalScheduledAction from combining interval and actionpublic static ScheduledAction error(java.lang.String statusMessage)
ScheduledAction which indicates that an unrecoverable error has occurred and the scheduler must
exit.
statusMessage is the same status message which is set by calling setStatusMessage(String)
statusMessage - To log indicating the details of the error. May be nullActionType.ERROR instance of ScheduledActionpublic static ScheduledAction exit(java.lang.String statusMessage)
ScheduledAction which indicates that the scheduler has reached the end of its life cycle
gracefully
statusMessage is the same status message which is set by calling setStatusMessage(String)
statusMessage - To log indicating the details of the error. May be nullActionType.EXIT instance of ScheduledActionpublic static ScheduledAction procedureCall(long interval, java.util.concurrent.TimeUnit timeUnit, java.util.function.Function<ActionResult,ScheduledAction> callback, java.lang.String procedure, java.lang.Object... procedureParameters)
ScheduledAction which executes a procedure with given parameters after intervalinterval - Interval after which the procedure is to be executedtimeUnit - {#link TimeUnit} of intervalcallback - That is invoked after procedure completes executionprocedure - Name of procedure to executeprocedureParameters - To pass to procedure during executionActionType.PROCEDURE instance of ScheduledActionpublic static ScheduledAction callback(long interval, java.util.concurrent.TimeUnit timeUnit, java.util.function.Function<ActionResult,ScheduledAction> callback)
ScheduledAction which causes the callback to be invoked after interval . A
ActionResult will be associated with this call however it will have a null procedure and
result but an attachment can be used.interval - Interval until the callback is invokedtimeUnit - TimeUnit of intervalcallback - That is invoked after interval has passedActionType.CALLBACK instance of ScheduledActionpublic long getInterval(java.util.concurrent.TimeUnit timeUnit)
timeUnit - Of the returned intervalpublic ActionType getType()
ActionType of this actionpublic java.lang.String getStatusMessage()
public ScheduledAction setStatusMessage(java.lang.String statusMessage)
ActionType.ERROR or ActionType.EXIT action then it will also be logged. For
ActionType.ERROR or ActionType.EXIT actions this can be provided as part of the factory method.statusMessage - To be reportedthispublic java.lang.String getProcedure()
null if this is not a ActionType.PROCEDUREpublic java.lang.Object[] getProcedureParameters()
getProcedure()public java.util.function.Function<ActionResult,ScheduledAction> getCallback()
action has been performedpublic ScheduledAction setAttachment(java.lang.Object attachment)
ActionResultattachment - Object to attach. May be nullthispublic <T> T getAttachment()
T - Type of attachmentnull of there was no attachmentpublic java.lang.String toString()
toString in class java.lang.Object