class JcrSession implements org.modeshape.jcr.api.Session {

    @Override
    public synchronized void logout() {
        // get the user id first, because calling terminate may cleanup the security context and loose this information
        String userID = getUserID();
        terminate(true);
        try {
            RunningState running = repository.runningState();
            long lifetime = Math.abs(System.nanoTime() - this.nanosCreated);
            Map<String, String> payload = Collections.singletonMap("userId", userID);
            running.statistics().recordDuration(DurationMetric.SESSION_LIFETIME, lifetime, TimeUnit.NANOSECONDS, payload);
            running.statistics().decrement(ValueMetric.SESSION_COUNT);
            running.removeSession(this);
        } catch (IllegalStateException e) {
            // The repository has been shutdown
        } finally {
            if (bufferMgr != null) {
                try {
                    bufferMgr.close();
                } finally {
                    bufferMgr = null;
                }
            }
        }
    }

    protected  JcrSession( JcrRepository repository,
                          String workspaceName,
                          ExecutionContext context,
                          Map<String, Object> sessionAttributes,
                          boolean readOnly );
    protected  JcrSession( JcrSession original,
                          boolean readOnly );

}