IN - the input data type.OUT - the output data type.public interface Invocation<IN,OUT>
<init>
| |
| |-------------------------------
V | |
---------------- |
--->|onInitialize()|----------- |
| ---------------- | |
| | ------ | |
| | | | | |
| V V | | |
| ---------------- | | |
| | onInput() |---- | |
| ---------------- V |
| | | ---------------- |
| | |-------->| onAbort() | |
| V | ---------------- |
| ---------------- | | |
| | onResult() | | | |
| ---------------- | | |
| | ------------- | |
| | | (if exception is thrown)
| V V | |
| ----------------- | |
----| onTerminate() | | |
----------------- | |
| -------------------------------
| |
V V
-----------------
| onDestroy() |
-----------------
Note that the onInput() method will be called for each input passed to the routine, so,
in case no input is expected, the onResult() method will be called soon after the
initialization.
Note also that onAbort() might be called at any time between onInitialize() and
onTerminate() in case the execution is aborted.
onTerminate() method does not get call at all, is when an
exception escapes the onAbort() method invocation.
The onTerminate() method is meant to allow the clean up and reset operations needed to
prepare the invocation object to be reused. When the method is not called or does not complete
successfully, the invocation object is discarded.onDestroy() method is meant to indicate that the invocation object is no longer
needed, so any associated resource can be safely released. Note that this method may never get
called if the routine is automatically garbage collected.
Keep in mind, when implementing an invocation class, that the result channel passed to the
onInput() and onResult() methods will be closed as soon as the latter exits.RoutineException, will be wrapped as the cause
of an InvocationException instance.
Created by davide-maestroni on 09/07/2014.| Modifier and Type | Method and Description |
|---|---|
void |
onAbort(RoutineException reason)
Called when the routine execution is aborted.
This method may be called at any time after the invocation initialization. |
void |
onDestroy()
Called when the routine invocation is no longer needed.
|
void |
onInitialize()
Called when the routine invocation is initialized.
This is always the first method in the invocation lifecycle. |
void |
onInput(IN input,
ResultChannel<OUT> result)
Called when an input is passed to the routine.
This method is called once for each input object. |
void |
onResult(ResultChannel<OUT> result)
Called when all the inputs has been passed to the routine.
This method is called once in the invocation lifecycle to indicate that the final invocation results should be passed to the result channel. |
void |
onTerminate()
Called when the invocation execution has completed.
|
void onAbort(@Nullable
RoutineException reason)
reason - the reason of the abortion.void onDestroy()
void onInitialize()
void onInput(IN input, @NotNull ResultChannel<OUT> result)
input - the input.result - the result channel.void onResult(@NotNull
ResultChannel<OUT> result)
result - the result channel.void onTerminate()