private void doShutdownListeners(HashSet shutdownListeners){
  if (shutdownListeners == null) {
    return;
  }
  Iterator it=shutdownListeners.iterator();
  while (it.hasNext()) {
    ShutdownListener s=(ShutdownListener)it.next();
    try {
      s.onShutdown(this);
    }
 catch (    VirtualMachineError err) {
      SystemFailure.initiateFailure(err);
      throw err;
    }
catch (    Throwable t) {
      SystemFailure.checkFailure();
      logger.fatal(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_SHUTDOWNLISTENER__0__THREW,s),t);
    }
  }
  for (; ; ) {
    DisconnectListener dcListener=null;
    ShutdownListener sdListener=null;
synchronized (this.listeners) {
      Iterator itr=listeners.iterator();
      if (!itr.hasNext()) {
        break;
      }
      dcListener=(DisconnectListener)itr.next();
      itr.remove();
      if (dcListener instanceof ShutdownListener) {
        sdListener=(ShutdownListener)dcListener;
      }
    }
    runDisconnect(dcListener,disconnectListenerThreadGroup);
    if (sdListener != null) {
      try {
        sdListener.onShutdown(this);
      }
 catch (      VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        throw err;
      }
catch (      Throwable t) {
        SystemFailure.checkFailure();
        logger.fatal(LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_DISCONNECTLISTENERSHUTDOWN_THREW),t);
      }
    }
  }
}

private void doShutdownListeners ( HashSet shutdownListeners ) { if ( shutdownListeners == null ) { return ; } Iterator it = shutdownListeners . iterator ( ) ; while ( it . hasNext ( ) ) { ShutdownListener s = ( ShutdownListener ) it . next ( ) ; try { s . onShutdown ( this ) ; } catch ( VirtualMachineError err ) { SystemFailure . initiateFailure ( err ) ; throw err ; } catch ( Throwable t ) { SystemFailure . checkFailure ( ) ; logger . fatal ( LocalizedMessage . create ( LocalizedStrings . InternalDistributedSystem_SHUTDOWNLISTENER__0__THREW , s ) , t ) ; } } for ( ; ; ) { DisconnectListener dcListener = null ; ShutdownListener sdListener = null ; synchronized ( this . listeners ) { Iterator itr = listeners . iterator ( ) ; if ( ! itr . hasNext ( ) ) { break ; } dcListener = ( DisconnectListener ) itr . next ( ) ; itr . remove ( ) ; if ( dcListener instanceof ShutdownListener ) { sdListener = ( ShutdownListener ) dcListener ; } } runDisconnect ( dcListener , disconnectListenerThreadGroup ) ; if ( sdListener != null ) { try { sdListener . onShutdown ( this ) ; } catch ( VirtualMachineError err ) { SystemFailure . initiateFailure ( err ) ; throw err ; } catch ( Throwable t ) { SystemFailure . checkFailure ( ) ; logger . fatal ( LocalizedMessage . create ( LocalizedStrings . InternalDistributedSystem_DISCONNECTLISTENERSHUTDOWN_THREW ) , t ) ; } } } }
process the shutdown listeners . it is essential that the dm has been shut down before calling this step , to ensure that no new listeners are registering .
