com.izforge.izpack.util
Class Housekeeper

java.lang.Object
  extended by com.izforge.izpack.util.Housekeeper

public class Housekeeper
extends java.lang.Object

This class performs housekeeping and cleanup tasks. There can only be one instance of Housekeeper per Java runtime, therefore this class is implemented as a 'Singleton'.

It is VERY important to perform pre-shutdown cleanup operations through this class. Do NOT rely on operations like deleteOnExit() shutdown hooks or finalize()for cleanup. Because shutDown() uses System.exit() to terminate, these methods will not work at all or will not work reliably.

Version:
0.0.1 / 2/9/02
Author:
Elmar Grom

Field Summary
private  java.util.Vector<CleanupClient> cleanupClients
           
private static Housekeeper me
           
 
Constructor Summary
private Housekeeper()
          This class is implemented as a 'Singleton'.
 
Method Summary
static Housekeeper getInstance()
          Returns an instance of Housekeeper to use.
 void registerForCleanup(CleanupClient client)
          Use to register objects that need to perform cleanup operations before the application shuts down.
 void shutDown(int exitCode)
          This methods shuts the application down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

me

private static Housekeeper me

cleanupClients

private java.util.Vector<CleanupClient> cleanupClients
Constructor Detail

Housekeeper

private Housekeeper()
This class is implemented as a 'Singleton'. Therefore the constructor is private to prevent instantiation of this class. Use getInstance() to obtain an instance for use.

For more information about the 'Singleton' pattern I highly recommend the book Design Patterns by Gamma, Helm, Johnson and Vlissides ISBN 0-201-63361-2.

Method Detail

getInstance

public static Housekeeper getInstance()
Returns an instance of Housekeeper to use.

Returns:
an instance of Housekeeper.

registerForCleanup

public void registerForCleanup(CleanupClient client)
Use to register objects that need to perform cleanup operations before the application shuts down.

Parameters:
client - reference of to an object that needs to perform cleanup operations.

shutDown

public void shutDown(int exitCode)
This methods shuts the application down. First, it will call all clients that have registered for cleanup operations. Once this has been accomplished, the application will be forceably terminated.

THIS METHOD DOES NOT RETURN!

Parameters:
exitCode - the exit code that should be returned to the calling process.