Package com.day.util
Class FinalizerHandler
- java.lang.Object
-
- com.day.util.FinalizerHandler
-
public class FinalizerHandler extends java.lang.Object
TheFinalizerHandler
class implements the functionality to registerFinalizer
s and call them at some point in time, such as the end of the currentExecutionContext
.The registered
Finalizer
s will be called in the reverse sequence of their registration. That is the lastFinalizer
registered will get called first.- Since:
- antbear Audience dev
-
-
Constructor Summary
Constructors Constructor Description FinalizerHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
callFinalizers()
Calls all registeredFinalizer
Finalizer.doFinalize()
method, and removes them from the internal list.boolean
isEmpty()
Returnstrue
if noFinalizer
objects are registered yet.void
registerObject(Finalizer object)
Registers aFinalizer
.void
unregister(Finalizer object)
Unregisters aFinalizer
object.void
unregisterAll()
Unregisters all registeredFinalizer
objects so that a subsequent call tocallFinalizers()
effectively does nothing.
-
-
-
Method Detail
-
registerObject
public void registerObject(Finalizer object)
Registers aFinalizer
.- Parameters:
object
- the finalzier to register
-
unregister
public void unregister(Finalizer object)
Unregisters aFinalizer
object. After unregistering the objectsdoFinalize()
method is not called anymore.- Parameters:
object
- TheFinalizer
object to unregister.
-
unregisterAll
public void unregisterAll()
Unregisters all registeredFinalizer
objects so that a subsequent call tocallFinalizers()
effectively does nothing.
-
isEmpty
public boolean isEmpty()
Returnstrue
if noFinalizer
objects are registered yet.- Returns:
- whether it's empty
-
callFinalizers
public void callFinalizers()
Calls all registeredFinalizer
Finalizer.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 aThrowable
is thrown this is logged as an error and processing continiues with the nextFinalizer
to be finalized.
-
-