ScopeObserver implements ScopePublisher { public void enterScope(final Scope scope) { if (scope == null) { LOGGER.warn("ignoring entered null scope"); return; } LOGGER.info("entering new scope '" + scope.getName() + "'..."); final Scope previous = currentScope(); scopes.push(scope); if (LOGGER.isDebugEnabled()) { LOGGER.debug("current scope stack: " + scopes); } synchronized (scopeSubscriber) { for (ScopeSubscriber listener : scopeSubscriber) { listener.enterScope(previous, scope); } } } ScopeObserver(); void enterScope(final Scope scope); void exitScope(final Scope scope); Scope currentScope(); void addScopeSubscriber(final ScopeSubscriber subscriber); void removeScopeSubscriber(final ScopeSubscriber subscriber);  }
@Test public void testEnterScope() { Assert.assertNull(observer.currentScope()); observer.enterScope(Scope.SESSION); Assert.assertEquals(Scope.SESSION, observer.currentScope()); observer.enterScope(Scope.APPLICATION); Assert.assertEquals(Scope.APPLICATION, observer.currentScope()); observer.enterScope(null); Assert.assertEquals(Scope.APPLICATION, observer.currentScope()); }