public void stop()
            throws Exception
    {
        if (!state.compareAndSet(State.STARTED, State.STOPPING)) {
            return;
        }

        Thread thread = shutdownHook.getAndSet(null);
        if (thread != null) {
            try {
                Runtime.getRuntime().removeShutdownHook(thread);
            }
            catch (IllegalStateException ignored) {
            }
        }

        log.info("Life cycle stopping...");

        List<Object> reversedInstances = new ArrayList<>(managedInstances);
        Collections.reverse(reversedInstances);

        for (Object obj : reversedInstances) {
            log.debug("Stopping %s", obj.getClass().getName());
            LifeCycleMethods methods = methodsMap.get(obj.getClass());
            for (Method preDestroy : methods.methodsFor(PreDestroy.class)) {
                log.debug("\t%s()", preDestroy.getName());
                preDestroy.invoke(obj);
            }
        }

        state.set(State.STOPPED);
        log.info("Life cycle stopped.");
    }
public void stop()
            throws Exception
    {
        if (!state.compareAndSet(State.STARTED, State.STOPPING)) {
            return;
        }

        Thread thread = shutdownHook.getAndSet(null);
        if (thread != null) {
            try {
                Runtime.getRuntime().removeShutdownHook(thread);
            }
            catch (IllegalStateException ignored) {
            }
        }

        log.info("Life cycle stopping...");

        List<Object> reversedInstances = new ArrayList<>(managedInstances);
        Collections.reverse(reversedInstances);

        for (Object obj : reversedInstances) {
            log.debug("Stopping %s", obj.getClass().getName());
            LifeCycleMethods methods = methodsMap.get(obj.getClass());
            for (Method preDestroy : methods.methodsFor(PreDestroy.class)) {
                log.debug("\t%s()", preDestroy.getName());
                preDestroy.invoke(obj);
            }
        }

        state.set(State.STOPPED);
        log.info("Life cycle stopped.");
    }
public void stop ( ) throws Exception { if ( ! state . compareAndSet ( State . STARTED , State . STOPPING ) ) { return ; } Thread thread = shutdownHook . getAndSet ( null ) ; if ( thread != null ) { try { Runtime . getRuntime ( ) . removeShutdownHook ( thread ) ; } catch ( IllegalStateException ignored ) { } } log . info ( "Life cycle stopping..." ) ; List < Object > reversedInstances = new ArrayList <> ( managedInstances ) ; Collections . reverse ( reversedInstances ) ; for ( Object obj : reversedInstances ) { log . debug ( "Stopping %s" , obj . getClass ( ) . getName ( ) ) ; LifeCycleMethods methods = methodsMap . get ( obj . getClass ( ) ) ; for ( Method preDestroy : methods . methodsFor ( PreDestroy . class ) ) { log . debug ( "\t%s()" , preDestroy . getName ( ) ) ; preDestroy . invoke ( obj ) ; } } state . set ( State . STOPPED ) ; log . info ( "Life cycle stopped." ) ; }
Stop the life cycle - all instances will have their {@link javax.annotation.PreDestroy} method(s) called

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