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.
|
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).
|
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()
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 is process and
that at least 1 statement in the block body will be executed before a
finished()
notification will occur.
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).