org.springframework.session.events.SessionExpiredEvent Java Examples
The following examples show how to use
org.springframework.session.events.SessionExpiredEvent.
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 |
private void deleteAndFireEvent(final String id, boolean expired) { final ExpiringSession deletedSession = sessions.remove(id); // Fire event if (deletedSession != null) { if (expired) { applicationEventPublisher.publishEvent(new SessionExpiredEvent(this, id)); } else { applicationEventPublisher.publishEvent(new SessionDeletedEvent(this, id)); } } }
Example #2
Source File: SessionEventHazelcastIndexedSessionRepositoryTests.java From spring-session with Apache License 2.0 | 6 votes |
@Test void expiredSessionTest() throws InterruptedException { S sessionToSave = this.repository.createSession(); this.repository.save(sessionToSave); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId())) .isInstanceOf(SessionCreatedEvent.class); this.registry.clear(); assertThat(sessionToSave.getMaxInactiveInterval()) .isEqualTo(Duration.ofSeconds(MAX_INACTIVE_INTERVAL_IN_SECONDS)); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); assertThat(this.registry.<SessionExpiredEvent>getEvent(sessionToSave.getId())) .isInstanceOf(SessionExpiredEvent.class); assertThat(this.repository.findById(sessionToSave.getId())).isNull(); }
Example #3
Source File: SessionEventHazelcastIndexedSessionRepositoryTests.java From spring-session with Apache License 2.0 | 6 votes |
@Test // gh-1300 void updateMaxInactiveIntervalTest() throws InterruptedException { S sessionToSave = this.repository.createSession(); sessionToSave.setMaxInactiveInterval(Duration.ofMinutes(30)); this.repository.save(sessionToSave); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId())) .isInstanceOf(SessionCreatedEvent.class); this.registry.clear(); S sessionToUpdate = this.repository.findById(sessionToSave.getId()); sessionToUpdate.setLastAccessedTime(Instant.now()); sessionToUpdate.setMaxInactiveInterval(Duration.ofSeconds(1)); this.repository.save(sessionToUpdate); assertThat(this.registry.receivedEvent(sessionToUpdate.getId())).isTrue(); assertThat(this.registry.<SessionExpiredEvent>getEvent(sessionToUpdate.getId())) .isInstanceOf(SessionExpiredEvent.class); assertThat(this.repository.findById(sessionToUpdate.getId())).isNull(); }
Example #4
Source File: SessionEventsListener.java From redisson with Apache License 2.0 | 5 votes |
@Override public void onApplicationEvent(AbstractSessionEvent event) { if (event instanceof SessionCreatedEvent) { sessionCreatedEvents++; } if (event instanceof SessionDeletedEvent) { sessionDeletedEvents++; } if (event instanceof SessionExpiredEvent) { sessionExpiredEvents++; } }
Example #5
Source File: WebSocketRegistryListenerTests.java From spring-session with Apache License 2.0 | 5 votes |
@BeforeEach void setup() { MockitoAnnotations.initMocks(this); String sessionId = "session-id"; MapSession session = new MapSession(sessionId); this.attributes = new HashMap<>(); SessionRepositoryMessageInterceptor.setSessionId(this.attributes, sessionId); given(this.wsSession.getAttributes()).willReturn(this.attributes); given(this.wsSession.getPrincipal()).willReturn(this.principal); given(this.wsSession.getId()).willReturn("wsSession-id"); given(this.wsSession2.getAttributes()).willReturn(this.attributes); given(this.wsSession2.getPrincipal()).willReturn(this.principal); given(this.wsSession2.getId()).willReturn("wsSession-id2"); Map<String, Object> headers = new HashMap<>(); headers.put(SimpMessageHeaderAccessor.SESSION_ATTRIBUTES, this.attributes); given(this.message.getHeaders()).willReturn(new MessageHeaders(headers)); this.listener = new WebSocketRegistryListener(); this.connect = new SessionConnectEvent(this.listener, this.wsSession); this.connect2 = new SessionConnectEvent(this.listener, this.wsSession2); this.disconnect = new SessionDisconnectEvent(this.listener, this.message, this.wsSession.getId(), CloseStatus.NORMAL); this.deleted = new SessionDeletedEvent(this.listener, session); this.expired = new SessionExpiredEvent(this.listener, session); }
Example #6
Source File: HazelcastIndexedSessionRepository.java From spring-session with Apache License 2.0 | 5 votes |
@Override public void entryEvicted(EntryEvent<String, MapSession> event) { if (logger.isDebugEnabled()) { logger.debug("Session expired with id: " + event.getOldValue().getId()); } this.eventPublisher.publishEvent(new SessionExpiredEvent(this, event.getOldValue())); }
Example #7
Source File: EnableRedisHttpSessionExpireSessionDestroyedTests.java From spring-session with Apache License 2.0 | 5 votes |
@Override public void onApplicationEvent(SessionExpiredEvent event) { synchronized (this.lock) { this.receivedEvent = true; this.lock.notifyAll(); } }
Example #8
Source File: RedisIndexedSessionRepository.java From spring-session with Apache License 2.0 | 4 votes |
private void handleExpired(RedisSession session) { publishEvent(new SessionExpiredEvent(this, session)); }