class ScopeObserver implements ScopePublisher {

    public void exitScope(final Scope scope) {
        if (scope == null) {
            LOGGER.warn("ignoring exited null scope");
            return;
        }

        LOGGER.info("exiting scope '" + scope.getName() + "'...");

        final int position = scopes.search(scope);
        if (position < 0) {
            LOGGER.warn("mismatched scope order. cannot exit '"
                        + scope.getName() + "'");
            LOGGER.warn("current scope stack: " + scopes);
            return;
        }

        for (int i = 0; i < position; i++) {
            scopes.pop();
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("current scope stack: " + scopes);
        }

        final Scope previous = currentScope();
        synchronized (scopeSubscriber) {
            for (ScopeSubscriber listener : scopeSubscriber) {
                listener.exitScope(scope, previous);
            }
        }
    }

    public  ScopeObserver();

}