tds/src/main/java/thredds/server/config/TdsInit.java
@Override
  public void destroy() {
    System.out.printf("TdsInit.destroy() is called%n");

    // prefs
    try {
      store.save();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      startupLog.error("TdsInit: Prefs save failed", ioe);
    }

    // background threads
    if (cdmDiskCacheTimer != null)
      cdmDiskCacheTimer.cancel();
    FileCache.shutdown();              // this handles background threads for all instances of FileCache
    DiskCache2.exit();                // this handles background threads for all instances of DiskCache2
    thredds.inventory.bdb.MetadataManager.closeAll();
    executor.shutdownNow();

    /* try {
      catalogWatcher.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      startupLog.error("catalogWatcher close failed", ioe);
    } */

    // open file caches
    RandomAccessFile.shutdown();
    NetcdfDataset.shutdown();

    // memory caches
    GribCdmIndex.shutdown();
    datasetManager.setDatasetTracker(null); // closes the existing tracker

    collectionUpdater.shutdown();
    startupLog.info("TdsInit shutdown");
    MDC.clear();
  }
@Override
  public void destroy() {
    System.out.printf("TdsInit.destroy() is called%n");

    // prefs
    try {
      store.save();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      startupLog.error("TdsInit: Prefs save failed", ioe);
    }

    // background threads
    if (cdmDiskCacheTimer != null)
      cdmDiskCacheTimer.cancel();
    FileCache.shutdown();              // this handles background threads for all instances of FileCache
    DiskCache2.exit();                // this handles background threads for all instances of DiskCache2
    thredds.inventory.bdb.MetadataManager.closeAll();
    executor.shutdownNow();

    /* try {
      catalogWatcher.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      startupLog.error("catalogWatcher close failed", ioe);
    } */

    // open file caches
    RandomAccessFile.shutdown();
    NetcdfDataset.shutdown();

    // memory caches
    GribCdmIndex.shutdown();
    datasetManager.setDatasetTracker(null); // closes the existing tracker

    collectionUpdater.shutdown();
    startupLog.info("TdsInit shutdown");
    MDC.clear();
  }
@ Override public void destroy ( ) { System . out . printf ( "TdsInit.destroy() is called%n" ) ; // prefs try { store . save ( ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; startupLog . error ( "TdsInit: Prefs save failed" , ioe ) ; } // background threads if ( cdmDiskCacheTimer != null ) cdmDiskCacheTimer . cancel ( ) ; FileCache . shutdown ( ) ; // this handles background threads for all instances of FileCache DiskCache2 . exit ( ) ; // this handles background threads for all instances of DiskCache2 thredds . inventory . bdb . MetadataManager . closeAll ( ) ; executor . shutdownNow ( ) ; /* try {
      catalogWatcher.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      startupLog.error("catalogWatcher close failed", ioe);
    } */ // open file caches RandomAccessFile . shutdown ( ) ; NetcdfDataset . shutdown ( ) ; // memory caches GribCdmIndex . shutdown ( ) ; datasetManager . setDatasetTracker ( null ) ; // closes the existing tracker collectionUpdater . shutdown ( ) ; startupLog . info ( "TdsInit shutdown" ) ; MDC . clear ( ) ; }
/*
http://stackoverflow.com/questions/24660408/how-can-i-get-intellij-debugger-to-allow-my-apps-shutdown-hooks-to-run?lq=1
"Unfortunately, you can't use breakpoints in your shutdown hook body when you use Stop button: these breakpoints are silently ignored."
/ * http : // stackoverflow . com / questions / 24660408 / how - can - i - get - intellij - debugger - to - allow - my - apps - shutdown - hooks - to - run?lq = 1 Unfortunately you can t use breakpoints in your shutdown hook body when you use Stop button : these breakpoints are silently ignored .