bootstrap/src/main/java/io/airlift/bootstrap/LifeCycleManager.java
public void start()
            throws Exception
    {
        if (!state.compareAndSet(State.LATENT, State.STARTING)) {
            throw new Exception("System already starting");
        }
        log.info("Life cycle starting...");

        for (Object obj : managedInstances) {
            LifeCycleMethods methods = methodsMap.get(obj.getClass());
            if (!methods.hasFor(PreDestroy.class)) {
                managedInstances.remove(obj);   // remove reference to instances that aren't needed anymore
            }
        }

        Thread thread = new Thread(() -> {
            try {
                stop();
            }
            catch (Exception e) {
                log.error(e, "Trying to shut down");
            }
        });
        shutdownHook.set(thread);
        Runtime.getRuntime().addShutdownHook(thread);

        state.set(State.STARTED);
        log.info("Life cycle startup complete. System ready.");
    }
public void start()
            throws Exception
    {
        if (!state.compareAndSet(State.LATENT, State.STARTING)) {
            throw new Exception("System already starting");
        }
        log.info("Life cycle starting...");

        for (Object obj : managedInstances) {
            LifeCycleMethods methods = methodsMap.get(obj.getClass());
            if (!methods.hasFor(PreDestroy.class)) {
                managedInstances.remove(obj);   // remove reference to instances that aren't needed anymore
            }
        }

        Thread thread = new Thread(() -> {
            try {
                stop();
            }
            catch (Exception e) {
                log.error(e, "Trying to shut down");
            }
        });
        shutdownHook.set(thread);
        Runtime.getRuntime().addShutdownHook(thread);

        state.set(State.STARTED);
        log.info("Life cycle startup complete. System ready.");
    }
public void start ( ) throws Exception { if ( ! state . compareAndSet ( State . LATENT , State . STARTING ) ) { throw new Exception ( "System already starting" ) ; } log . info ( "Life cycle starting..." ) ; for ( Object obj : managedInstances ) { LifeCycleMethods methods = methodsMap . get ( obj . getClass ( ) ) ; if ( ! methods . hasFor ( PreDestroy . class ) ) { managedInstances . remove ( obj ) ; // remove reference to instances that aren't needed anymore } } Thread thread = new Thread ( ( ) -> { try { stop ( ) ; } catch ( Exception e ) { log . error ( e , "Trying to shut down" ) ; } } ) ; shutdownHook . set ( thread ) ; Runtime . getRuntime ( ) . addShutdownHook ( thread ) ; state . set ( State . STARTED ) ; log . info ( "Life cycle startup complete. System ready." ) ; }
Start the life cycle - all instances will have their {@link javax.annotation.PostConstruct} method(s) called

@throws Exception errors
Start the life cycle - all instances will have their { @link javax . annotation . PostConstruct } method ( s ) called