class SessionManager implements Closeable {

  public RepositoryBackedSession getSession(RequestWithSession request, boolean create,
      SessionTracking.IdAndSource forceId) {
    SessionTracking.IdAndSource id = retrieveId(request, forceId);
    RepositoryBackedSession session = null;
    if (id != null && id.id != null) {
      putIdInLoggingMdc(id.id);
      request.setRequestedSessionId(id.id, id.cookie);
      session = fetchSession(id.id, true);
      if (!request.isRepositoryChecked()) {
        logger.info("Session with sessionId: '{}' but it was not in repository!", id);
        request.repositoryChecked();
      }
    } else {
      // Session is null, assume default tracking
      putIdInLoggingMdc(null);
      request.setRequestedSessionId(null, tracking.isCookieTracking());
    }
    if (session == null && create) {
      if (forceId == null) {
        id = new SessionTracking.IdAndSource(tracking.newId(), tracking.isCookieTracking());
      } else {
        id = forceId;
      }
      putIdInLoggingMdc(id.id);
      logger.info("Creating new session with sessionId: '{}'", id);
      session = newSession(id.id);
    }
    if (session != null) {
      session.checkUsedAndLock();
    }
    return session;
  }

  public  SessionManager(ExecutorFacade executors, SessionFactory factory, SessionRepository repository,
      SessionTracking tracking, SessionNotifier notifier, SessionConfiguration configuration, ClassLoader classLoader);

}