public interface Finalizable
Modifier and Type | Method and Description |
---|---|
void |
deleted()
Provides a notification that the external program in which the object is registered is
being deleted and the object's reference may be lost after this method is called.
|
default void |
entry()
Notification which is called once (and only ever once) after the one-time block
initialization (the
Block.init() and before the block body Block.body()
executes for the first time. |
void |
finished()
Provides a notification that the scope in which the object is
registered is ending and the object's reference may or may not be lost after
this method is called.
|
default void |
initFailure()
Provides a notification that procedure this object was registered failed initialization and
allows eventual cleanup to be performed.
|
void |
iterate()
Provides a notification that the block whose scope in which the object is registered is
about to iterate and attempt another pass.
|
void |
retry()
Provides a notification that the block whose scope in which the object
is registered is about to retry the same iteration (all loop control
data is unchanged).
|
default WeightFactor |
weight()
Get the weight of this finalizable.
|
void finished()
This processing is guaranteed to be called after all processing of the
block body has occurred, no matter whether the exit from the block is
occurring due to natural flow control (the end of the block was
reached), a continue
, a return
, an exception
was thrown or an error raised.
If this is called, one can be sure that iterate()
and
retry()
have not been called without the loop body executing
afterwards (but before this notification occurred).
default void initFailure()
finished()
will not be
called because the scope of the procedure haven't started yet.
Usually the implementation will call finished()
if the registration occurs before
the procedure scope was started and some preparations that need rollback were made.
Otherwise this method should be kept empty.
void deleted()
default void entry()
Block.init()
and before the block body Block.body()
executes for the first time. This is the counterpart to iterate()
except it occurs
at the top of the first iteration (or the first block execution for non-loops) instead of
only being called on the second and subsequent iterations. iterate()
is not
called for the first iteration of a loop (and is never called for non-loops).void iterate()
This hook is called at the top of the loop, just after the loop test has been passed. If the loop test fails, then this will not be called. This code will be called inside the block itself, as the first thing that is done.
Note that this is only called on the second and subsequent iterations of the block, no
matter how the iteration occurred (via natural control flow through the bottom of an
iterating block OR via a Java continue
statement that caused a jump to the top of
the loop).
If the block is not a loop (an iterating block), this method will NOT be executed.
If this is called, one can be sure that a retry is NOT in process and that at least 1
statement in the block body will be executed before a finished()
notification will
occur.
On the first iteration (or the non-loop block execution) the entry()
will be
called instead of iterate()
. iterate()
is never called in those cases.
void retry()
This hook is called at the bottom of the block, before iterating or exiting IF AND ONLY IF a retry is about to occur. On a retry, the loop condition of any iterating block will not be subsequently executed, nor will there be any backup/snapshot of undoable variables.
If this is called, one can be sure that neither an iterate()
nor a finished()
notification will occur before at least 1
statement in the block body is executed.
A retry can occur whether or not this is an iterating block (a loop).
default WeightFactor weight()
weight
, before they are processed.WeightFactor.LAST
.