Java Code Examples for org.apache.catalina.Session#getCreationTime()

The following examples show how to use org.apache.catalina.Session#getCreationTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JspHelper.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static String getDisplayInactiveTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getInactiveTimeForSession(in_session)/1000);
}
 
Example 2
Source File: ManagerBase.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public Session createSession(String sessionId) {
    
    if ((maxActiveSessions >= 0) &&
            (getActiveSessions() >= maxActiveSessions)) {
        rejectedSessions++;
        throw new TooManyActiveSessionsException(
                sm.getString("managerBase.createSession.ise"),
                maxActiveSessions);
    }
    
    // Recycle or create a Session instance
    Session session = createEmptySession();

    // Initialize the properties of the new session and return it
    session.setNew(true);
    session.setValid(true);
    session.setCreationTime(System.currentTimeMillis());
    session.setMaxInactiveInterval(((Context) getContainer()).getSessionTimeout() * 60);
    String id = sessionId;
    if (id == null) {
        id = generateSessionId();
    }
    session.setId(id);
    sessionCounter++;

    SessionTiming timing = new SessionTiming(session.getCreationTime(), 0);
    synchronized (sessionCreationTiming) {
        sessionCreationTiming.add(timing);
        sessionCreationTiming.poll();
    }
    return (session);

}
 
Example 3
Source File: SessionUtils.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 4
Source File: JspHelper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static String getDisplayInactiveTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getInactiveTimeForSession(in_session)/1000);
}
 
Example 5
Source File: JspHelper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static String getDisplayTTLForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getTTLForSession(in_session)/1000);
}
 
Example 6
Source File: JspHelper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static String getDisplayUsedTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getUsedTimeForSession(in_session)/1000);
}
 
Example 7
Source File: JspHelper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static String getDisplayCreationTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
        DateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
        return formatter.format(new Date(in_session.getCreationTime()));
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
}
 
Example 8
Source File: SessionUtils.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 9
Source File: JspHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static String getDisplayCreationTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
        DateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
        return formatter.format(new Date(in_session.getCreationTime()));
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
}
 
Example 10
Source File: JspHelper.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static String getDisplayTTLForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getTTLForSession(in_session)/1000);
}
 
Example 11
Source File: JspHelper.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static String getDisplayUsedTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getUsedTimeForSession(in_session)/1000);
}
 
Example 12
Source File: JspHelper.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static String getDisplayCreationTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
        DateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
        return formatter.format(new Date(in_session.getCreationTime()));
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
}
 
Example 13
Source File: ManagerBase.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public Session createSession(String sessionId) {

    if ((maxActiveSessions >= 0) &&
            (getActiveSessions() >= maxActiveSessions)) {
        rejectedSessions++;
        throw new TooManyActiveSessionsException(
                sm.getString("managerBase.createSession.ise"),
                maxActiveSessions);
    }

    // Recycle or create a Session instance
    Session session = createEmptySession();

    // Initialize the properties of the new session and return it
    session.setNew(true);
    session.setValid(true);
    session.setCreationTime(System.currentTimeMillis());
    session.setMaxInactiveInterval(getContext().getSessionTimeout() * 60);
    String id = sessionId;
    if (id == null) {
        id = generateSessionId();
    }
    session.setId(id);
    sessionCounter++;

    SessionTiming timing = new SessionTiming(session.getCreationTime(), 0);
    synchronized (sessionCreationTiming) {
        sessionCreationTiming.add(timing);
        sessionCreationTiming.poll();
    }
    return session;
}
 
Example 14
Source File: SessionUtils.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static long getUsedTimeForSession(Session in_session) {
    try {
        long diffMilliSeconds = in_session.getThisAccessedTime() - in_session.getCreationTime();
        return diffMilliSeconds;
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return -1;
    }
}
 
Example 15
Source File: JspHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static String getDisplayInactiveTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getInactiveTimeForSession(in_session)/1000);
}
 
Example 16
Source File: JspHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static String getDisplayTTLForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getTTLForSession(in_session)/1000);
}
 
Example 17
Source File: JspHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static String getDisplayUsedTimeForSession(Session in_session) {
    try {
        if (in_session.getCreationTime() == 0) {
            return "";
        }
    } catch (IllegalStateException ise) {
        //ignore: invalidated session
        return "";
    }
    return secondsToTimeString(SessionUtils.getUsedTimeForSession(in_session)/1000);
}
 
Example 18
Source File: ManagerBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public long getCreationTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getCreationTime();
}
 
Example 19
Source File: ManagerBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public long getCreationTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getCreationTime();
}
 
Example 20
Source File: ManagerBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public long getCreationTimestamp( String sessionId ) {
    Session s=sessions.get(sessionId);
    if(s== null)
        return -1 ;
    return s.getCreationTime();
}