xmlBlaster 2.2.0 client API

org.xmlBlaster.util
Class SignalCatcher

java.lang.Object
  extended by org.xmlBlaster.util.SignalCatcher
All Implemented Interfaces:
java.lang.Runnable

public class SignalCatcher
extends java.lang.Object
implements java.lang.Runnable

SignalCatcher catches Ctrl-C and does the desired action.

Works only with JDK 1.3 and above, we check with reflection the availability to still be JDK 1.2 compatible.

Author:
Marcel Ruff.

Constructor Summary
SignalCatcher()
           
 
Method Summary
 boolean catchSignals()
          Add shutdown hook.
 boolean hasListener()
           
static SignalCatcher instance()
           
 void register(I_SignalListener listener)
          You need to call init() after construction.
 boolean removeSignalCatcher()
           
 void run()
          This is invoked on exit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignalCatcher

public SignalCatcher()
Method Detail

instance

public static SignalCatcher instance()

hasListener

public boolean hasListener()

register

public void register(I_SignalListener listener)
You need to call init() after construction. Example for a hook:
  class Shutdown extends Thread {
    public void run() {
       System.exit(0);
    }
  }
  SignalCatcher c = SignalCatcher.instance();
  c.register(new Shutdown());
  c.catchSignals();
  ...
  c.removeSignalCatcher();
 

Throws:
java.lang.IllegalArgumentException - if other listener exists

catchSignals

public boolean catchSignals()
Add shutdown hook.

Catch signals, e.g. Ctrl C to stop xmlBlaster.
Uses reflection since only JDK 1.3 supports it.

NOTE: On Linux build 1.3.0, J2RE 1.3.0 IBM build cx130-20000815 (JIT enabled: jitc) fails with Ctrl-C

Returns:
true: Shutdown hook is established

removeSignalCatcher

public boolean removeSignalCatcher()
Returns:
true on success

run

public void run()
This is invoked on exit

Specified by:
run in interface java.lang.Runnable

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.