Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
サーバーのシャットダウンを取得するリスナーインターフェイスです。
public interface ShutdownListener
継承されたメンバーを含む ShutdownListener インターフェイスのすべてのメンバー。
shutdownPerformed メソッド
このインターフェイスを使用して、Mobile Link サーバーが終了する前に、スレッド、接続、およびその他のリソースがすべてクリーンアップされるようにします。
次に、ServerContext インスタンスの ShutdownListener オブジェクトをインストールする方法の例を示します。
class MyShutdownListener implements ShutdownListener { FileOutputStream _outFile; public MyShutdownListener(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(); } // ... } }
次のコードは、MyShutdownListener オブジェクトを登録します。クラスコンストラクターや同期スクリプトなど、ServerContext にアクセスできる任意の場所からこのコードを呼び出してください。
ServerContext serv_context; FileOutputStream outFile; serv_context.addShutdownListener(new MyShutdownListener(outFile));