Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » MobiLink - Server Administration » MobiLink Server APIs » Writing synchronization scripts in Java » MobiLink server API for Java Reference

 

ShutdownListener interface

Syntax
public ianywhere.ml.script.ShutdownListener
Remarks

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

Members

All members of ianywhere.ml.script.ShutdownListener, including all inherited members.

Example

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.

// ServerContext serv_context;
// FileOutputStream outFile
serv_context.addShutdownListener(
      new MyShutdownListener( outFile ));

shutdownPerformed method