The listener interface for catching server shutdowns. Use this interface to ensure that all threads, connections, and other
resources are cleaned up before the server exits
The following code installs a ShutdownListener for the ServerContext.
class MyShutdownListener implements ShutdownListener {
FileOutputStream _outFile;
public MySutdownListener(FileOutputStream outFile) {
_outFile = outFile;
}
public void shutdownPerformed(ServerContext sc) {
// Add shutdown code
try {
_outFile.write(("Shutting Down" + "\n").getBytes());
_outFile.flush();
}
catch(Exception e) {
// Print some error output to the MobiLink log.
e.printStackTrace();
}
// ...
}
}
The following code registers MyShutdownListener. Call this code from anywhere that has access to the ServerContext such as
a class constructor or synchronization script.