Package com.day.util
Class FinalizerHandler
java.lang.Object
com.day.util.FinalizerHandler
The
FinalizerHandler class implements the functionality to
register Finalizers and call them at some point in time, such as
the end of the current ExecutionContext.
The registered Finalizers will be called in the reverse sequence
of their registration. That is the last Finalizer registered will
get called first.
- Since:
- antbear Audience dev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalls all registeredFinalizerFinalizer.doFinalize()method, and removes them from the internal list.booleanisEmpty()Returnstrueif noFinalizerobjects are registered yet.voidregisterObject(Finalizer object) Registers aFinalizer.voidunregister(Finalizer object) Unregisters aFinalizerobject.voidUnregisters all registeredFinalizerobjects so that a subsequent call tocallFinalizers()effectively does nothing.
-
Constructor Details
-
FinalizerHandler
public FinalizerHandler()
-
-
Method Details
-
registerObject
Registers aFinalizer.- Parameters:
object- the finalzier to register
-
unregister
Unregisters aFinalizerobject. After unregistering the objectsdoFinalize()method is not called anymore.- Parameters:
object- TheFinalizerobject to unregister.
-
unregisterAll
public void unregisterAll()Unregisters all registeredFinalizerobjects so that a subsequent call tocallFinalizers()effectively does nothing. -
isEmpty
public boolean isEmpty()Returnstrueif noFinalizerobjects are registered yet.- Returns:
- whether it's empty
-
callFinalizers
public void callFinalizers()Calls all registeredFinalizerFinalizer.doFinalize()method, and removes them from the internal list.The call to the
Finalizer.doFinalize()is not expected to throw any exceptions or even errors. In case aThrowableis thrown this is logged as an error and processing continiues with the nextFinalizerto be finalized.
-