public abstract class StepExecution extends Object implements Serializable
Step
, and provides insights into what's going on
asynchronously and aborting the activity if need be.
StepExecution
s are persisted whenever used to run an asynchronous operation.
Step.start(StepContext)
,
Serialized FormModifier | Constructor and Description |
---|---|
protected |
StepExecution()
Deprecated.
Avoid Guice.
|
protected |
StepExecution(StepContext context)
If manually created,
StepContext must be passed in. |
Modifier and Type | Method and Description |
---|---|
static <T extends StepExecution> |
applyAll(Class<T> type,
com.google.common.base.Function<T,Void> f)
Applies only to the specific subtypes.
|
static com.google.common.util.concurrent.ListenableFuture<?> |
applyAll(com.google.common.base.Function<StepExecution,Void> f)
Apply the given function to all the active running
StepExecution s in the system. |
StepContext |
getContext() |
String |
getStatus()
May be overridden to provide specific information about what a step is currently doing, for diagnostic purposes.
|
String |
getStatusBounded(long timeout,
TimeUnit unit)
Like
getStatus() but more robust. |
void |
onResume()
Called when
StepExecution is brought back into memory after restart. |
abstract boolean |
start()
Start execution of something and report the end result back to the given callback.
|
abstract void |
stop(Throwable cause)
May be called if someone asks a running step to abort.
|
String |
toString() |
@Deprecated protected StepExecution()
protected StepExecution(@Nonnull StepContext context)
StepContext
must be passed in.@Nonnull public StepContext getContext()
public abstract boolean start() throws Exception
StepContext.onSuccess(Object)
or FutureCallback.onFailure(Throwable)
.
false if the asynchronous execution has started and that StepContext
will be notified when the result comes in. (Note that the nature of asynchrony is such that it is possible
for the StepContext
to be already notified before this method returns.)Exception
- if any exception is thrown, Step
is assumed to have completed abnormally synchronously
(as if FutureCallback.onFailure(java.lang.Throwable)
is called and the method returned true.)public abstract void stop(@Nonnull Throwable cause) throws Exception
Thread.interrupt()
,
the step might not honor the request immediately.
Multiple stop requests might be sent.
It is always responsible for calling StepContext.onSuccess(Object)
or (more likely)
FutureCallback.onFailure(Throwable)
eventually,
whether or not it was asked to stop.
In the workflow context, this method is meant to be used by FlowExecution
, and not
to be called willy-nilly from UI or other human requests to pause. Use BodyExecution.cancel(Throwable)
.
cause
- Contextual information that lets the step know what resulted in stopping an executing step,
passed in the hope that this will assist diagnostics.Exception
public void onResume()
StepExecution
is brought back into memory after restart.
Convenient for re-establishing the polling.@CheckForNull public String getStatus()
getStatusBounded(long, java.util.concurrent.TimeUnit)
@CheckForNull public final String getStatusBounded(long timeout, TimeUnit unit)
getStatus()
but more robust.
Waits a most a given amount of time for the result, and handles RuntimeException
s.timeout
- maximum amount of time to spendunit
- time unitpublic static com.google.common.util.concurrent.ListenableFuture<?> applyAll(com.google.common.base.Function<StepExecution,Void> f)
StepExecution
s in the system.StepExecutionIterator
public static <T extends StepExecution> com.google.common.util.concurrent.ListenableFuture<?> applyAll(Class<T> type, com.google.common.base.Function<T,Void> f)
Copyright © 2016–2017. All rights reserved.