@Override
    public DeactivatedContainer activateContainer(ContainerBuilder builder) {
        ActiveContainer next = builder != null ? new ActiveContainer(builder) : null;
        final ActiveContainer prev;
        synchronized (appLock) {
            if (application == null && next != null) {
                next.release();
                throw new ApplicationNotReadyException();
            }

            if (next != null) {
                next.retainReference(applicationInUseTracker);
            }

            watchdog.onContainerActivation(next);
            prev = containerRef.getAndSet(next);
            if (prev == null) {
                return null;
            }
        }
        prev.release();
        return prev.shutdown();
    }
@author Simon Thoresen Hult
@author bjorncs
jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java