public void shutdown() {
        if (bootstrapped.compareAndSet(true, false)) {
            LOGGER.info("Shutting down Jashing...");

            injector.getInstance(ServiceManager.class).stopAsync().awaitStopped();
            injector.getInstance(JashingServer.class).stopAsync().awaitTerminated();


            /* shutdown method might be called by this hook. So, trying to remove
             * hook which is currently is progress causes error
             */
            if (!shutdownHook.isAlive()) {
                Runtime.getRuntime().removeShutdownHook(shutdownHook);
            }
            LOGGER.info("Jashing has stopped.");
        } else {
            throw new IllegalStateException("Jashing is not bootstrapped");
        }
    }
public void shutdown ( ) { if ( bootstrapped . compareAndSet ( true , false ) ) { LOGGER . info ( "Shutting down Jashing..." ) ; injector . getInstance ( ServiceManager . class ) . stopAsync ( ) . awaitStopped ( ) ; injector . getInstance ( JashingServer . class ) . stopAsync ( ) . awaitTerminated ( ) ; if ( ! shutdownHook . isAlive ( ) ) { Runtime . getRuntime ( ) . removeShutdownHook ( shutdownHook ) ; } LOGGER . info ( "Jashing has stopped." ) ; } else { throw new IllegalStateException ( "Jashing is not bootstrapped" ) ; } }
Shutdowns Jashing. Permitted only for bootstrapped instance