code: public void onApplicationEvent(ApplicationEvent event)
      {
          if ((event instanceof LoginEvent)
                  && (event.getSource() != LoginEvent.NO_AUTHENTICATION))
              handleLoginEvent((LoginEvent) event);
          else if ((event instanceof LogoutEvent))
              handleLogoutEvent((LogoutEvent) event);
      }
docs: Handle events that influence the session/user context.