Package org.zkoss.util
Class Cleanups
- java.lang.Object
-
- org.zkoss.util.Cleanups
-
public class Cleanups extends java.lang.ObjectUtilities to clean up resources when the application is stopping. Currently, when a ZK application is stopping, ZK will invokecleanup(). Thus you can register an implementation ofCleanups.Cleanupto release the resources.Notice that this utility is introduced mainly to resolve the memory lead issue if an application is hot re-deployed. A typical example is to stop any pooled threads.
How to use:
First, register the cleanup with
add(org.zkoss.util.Cleanups.Cleanup).Second, invoke
.cleanup()when necessary, such as when the application is stopping- Since:
- 3.6.5
- Author:
- tomyeh
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCleanups.CleanupThe interface to implement for each cleanup.
-
Constructor Summary
Constructors Constructor Description Cleanups()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanadd(Cleanups.Cleanup cleanup)Registers a cleanup.static voidcleanup()Invokes all cleanups registered withadd(org.zkoss.util.Cleanups.Cleanup).static booleanremove(Cleanups.Cleanup cleanup)Un-registers a cleanup.
-
-
-
Method Detail
-
add
public static boolean add(Cleanups.Cleanup cleanup)
Registers a cleanup.- Returns:
- true if it is added successfully, or false if the cleanup has been registered before.
-
remove
public static boolean remove(Cleanups.Cleanup cleanup)
Un-registers a cleanup.- Returns:
- true if it is removed successfully, or false if not registered before.
-
cleanup
public static void cleanup()
Invokes all cleanups registered withadd(org.zkoss.util.Cleanups.Cleanup).
-
-