@Retention(value=SOURCE) @Target(value=TYPE) public @interface OnStop
Runnable
or
Callable
<Boolean>
subclasses with default constructor
which will be invoked during shutdown sequence or when the module
is being shutdown.
First of all call callables are consulted to allow or deny proceeding with the shutdown:
@OnStop
public class AskTheUser implements Callable<Boolean> {
public Boolean call() {
return isItOKToShutdown() ? Boolean.TRUE : Boolean.FALSE;
}
}
If the shutdown is approved, all runnables registered are acknowledged and
can perform the shutdown cleanup. The runnables are invoked in parallel.
It is guaranteed their execution is finished before the shutdown sequence
is over:
@OnStop
public class Cleanup implements Runnable {
public void run() {
// do some cleanup
}
}