Java Code Examples for org.springframework.session.ExpiringSession#isExpired()

The following examples show how to use org.springframework.session.ExpiringSession#isExpired() . 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: FixedMapSessionRepository.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ExpiringSession getSession(final String id)
{
	final ExpiringSession saved = sessions.get(id);
	if (saved == null)
	{
		return null;
	}
	if (saved.isExpired())
	{
		final boolean expired = true;
		deleteAndFireEvent(saved.getId(), expired);
		return null;
	}

	return new MapSession(saved);
}
 
Example 2
Source File: FixedMapSessionRepository.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 6 votes vote down vote up
public void purgeExpiredSessions()
{
	final Stopwatch stopwatch = Stopwatch.createStarted();
	int countExpiredSessions = 0;

	final List<ExpiringSession> sessionsToCheck = new ArrayList<>(sessions.values());
	for (final ExpiringSession session : sessionsToCheck)
	{
		if (session.isExpired())
		{
			deleteAndFireEvent(session.getId(), true /* expired */);
			countExpiredSessions++;
		}
	}

	logger.debug("Purged {}/{} expired sessions in {}", countExpiredSessions, sessionsToCheck.size(), stopwatch);
}
 
Example 3
Source File: SpringSessionBackedSessionInformation.java    From spring-session-concurrent-session-control with Apache License 2.0 5 votes vote down vote up
public SpringSessionBackedSessionInformation(ExpiringSession session, SessionRepository<? extends ExpiringSession> sessionRepository) {
    super(resolvePrincipal(session), session.getId(), new Date(session.getLastAccessedTime()));
    this.sessionRepository = sessionRepository;
    if (session.isExpired()) {
        super.expireNow();
    }
}