use of org.springframework.session.ExpiringSession in project metasfresh-webui-api by metasfresh.
the class FixedMapSessionRepository method createSession.
@Override
public ExpiringSession createSession() {
final ExpiringSession result = new MapSession();
if (defaultMaxInactiveInterval != null) {
result.setMaxInactiveIntervalInSeconds(defaultMaxInactiveInterval);
}
// Fire event
applicationEventPublisher.publishEvent(new SessionCreatedEvent(this, result.getId()));
return result;
}
use of org.springframework.session.ExpiringSession in project metasfresh-webui-api by metasfresh.
the class FixedMapSessionRepository method getSession.
@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);
}
use of org.springframework.session.ExpiringSession in project metasfresh-webui-api by metasfresh.
the class FixedMapSessionRepository method purgeExpiredSessions.
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);
countExpiredSessions++;
}
}
logger.debug("Purged {}/{} expired sessions in {}", countExpiredSessions, sessionsToCheck.size(), stopwatch);
}
Aggregations