/** * Registers a shutdown hook for all current and future ConnectionPoolManager * instances to ensure they are released if the JVM exits with any managers * having not been released. * <p><strong>Note:</strong> All individual shutdown hooks will be unregistered * and replaced with this single shutdown hook. */ public static synchronized void registerGlobalShutdownHook() { if (shutdownHookGlobal != null) return; try { shutdownHookGlobal = new Releaser(); Runtime.getRuntime().addShutdownHook(shutdownHookGlobal); logShared.info("Registered global ConnectionPoolManager shutdown-hook"); // Remove instance hooks. for (ConnectionPoolManager cpm : getInstances()) cpm.removeShutdownHook(); } catch (Exception ex) { logShared.warn("Error registering global ConnectionPoolManager shutdown-hook", ex); } }