Example usage for org.apache.wicket Session getSizeInBytes

List of usage examples for org.apache.wicket Session getSizeInBytes

Introduction

In this page you can find the example usage for org.apache.wicket Session getSizeInBytes.

Prototype

public final long getSizeInBytes() 

Source Link

Usage

From source file:fiftyfive.wicket.util.LoggingUtils.java

License:Apache License

/**
 * Returns a Map with information associated with the following keys:
 * <ul>/*from w w w . ja va 2  s .c om*/
 * <li>{@code ID}</li>
 * <li>{@code Info} (if session implements {@link ISessionLogInfo})</li>
 * <li>{@code Size}</li>
 * <li>{@code Duration} (if {@link IRequestLogger} is enabled)</li>
 * </ul>
 */
public static Map<String, Object> getSessionInfo() {
    Session sess = Session.get();
    Object detail = "--ISessionLogInfo not implemented--";

    if (sess instanceof ISessionLogInfo) {
        detail = ((ISessionLogInfo) sess).getSessionInfo();
    }

    Map<String, Object> info = new LinkedHashMap<String, Object>();
    if (sess != null) {
        info.put("ID", sess.getId());
        info.put("Info", detail);
        info.put("Size", Bytes.bytes(sess.getSizeInBytes()));

        Duration dur = getSessionDuration();
        if (dur != null) {
            info.put("Duration", getSessionDuration());
        }
    }
    return info;
}