List of usage examples for org.apache.wicket.protocol.http IRequestLogger getLiveSessions
SessionData[] getLiveSessions();
From source file:fiftyfive.wicket.util.LoggingUtils.java
License:Apache License
/** * Returns the amount of time the currently session has been active. * Depends on Wicket's {@link IRequestLogger} being enabled. If it is not, * returns {@code null}./*from ww w.ja v a2 s. c o m*/ */ public static Duration getSessionDuration() { Date start = null; Session currSession = Session.get(); IRequestLogger log = Application.get().getRequestLogger(); if (log != null && currSession != null && currSession.getId() != null) { String sessionId = currSession.getId(); SessionData[] sessions = log.getLiveSessions(); if (sessions != null) { for (SessionData sess : sessions) { if (sessionId.equals(sess.getSessionId())) { start = sess.getStartDate(); break; } } } } return nullSafeElapsed(start); }
From source file:fiftyfive.wicket.util.LoggingUtils.java
License:Apache License
/** * Returns a string that describes the active sessions in this format: * {@code 5 (16 peak)}. This information comes from the application's * {@link IRequestLogger}. If the logger is not enabled, returns * {@code null}.// ww w. j ava2s .c o m */ public static String describeActiveSessions() { IRequestLogger log = Application.get().getRequestLogger(); if (null == log) return null; SessionData[] sessions = log.getLiveSessions(); if (null == sessions) return null; return String.format("%d (%d peak)", sessions.length, log.getPeakSessions()); }