public interface ScheduledContext
TriggerStrategy implementations need to take care of supporting the scheduled
context theirself.
An instance of this class is available for injection. It is bound as scoped proxy and can thus also be injected into singletons. However, calling methods on the proxy'ed context will only work if the context is active for the current thread.
ScheduledScope,
RunnableBuilder| Modifier and Type | Method and Description |
|---|---|
void |
beginNewExecution()
Records the start of a new execution performed in the current thread.
|
void |
cancel(boolean mayInterrupt)
Cancels this scheduled method.
|
void |
finishExecution()
Detaches the
ExecutionContext from the current thread and thus closes the
current execution scope. |
ExecutionContext |
getExecution()
Gets the current execution context.
|
int |
getExecutionCount()
Gets the number of times that this method has been executed.
|
Method |
getMethod()
Gets the scheduled method to which this scope belongs.
|
Map<String,Object> |
getProperties()
Gets the properties that are attached to this context.
|
boolean |
isCancelled()
Returns true if cancel has been called on this context.
|
void |
setFuture(Future<?> future)
Sets the Future object for controlling the scheduled task.
|
Method getMethod()
void beginNewExecution()
ExecutionContext which will be attached to the current thread until
finishExecution() is called.ExecutionScopevoid finishExecution()
ExecutionContext from the current thread and thus closes the
current execution scope. Must be called from within the same thread from which
beginNewExecution() has been called in order to close the correct context.ExecutionScopeMap<String,Object> getProperties()
ScheduledScope implementation to store cached objects.int getExecutionCount()
ExecutionContext.getExecutionNr() to figure out the number of the current
execution.
Since version 1.1.0 this number no longer denotes the number of times that the method had finished executing. It now returns the number of times that the method has been called, disregarding whether all calls have already returned.
ExecutionContext getExecution()
void cancel(boolean mayInterrupt)
In case the scheduled method is not contained in a singleton scoped object it will be scheduled again once another instance of the object has been created. If the scheduled method was a static one, it will never be scheduled again.
mayInterrupt - Whether running executions may be interrupted.boolean isCancelled()
void setFuture(Future<?> future)
TriggerStrategy implementations to make the context support the
cancel(boolean) method. If no Future object is set by the strategy,
canceling will not be possible.future - The Future object obtained from the scheduler.Copyright © 2014–2018. All rights reserved.