Search in sources :

Example 1 with SessionCreatedEvent

use of io.micronaut.session.event.SessionCreatedEvent in project micronaut-core by micronaut-projects.

the class InMemorySessionStore method save.

@Override
public CompletableFuture<InMemorySession> save(InMemorySession session) {
    if (session == null) {
        throw new IllegalArgumentException("Session cannot be null");
    }
    String id = session.getId();
    session.setNew(false);
    InMemorySession existing = sessions.getIfPresent(id);
    // result in the expiry interval being reset so nothing else needs to be done
    if (session != existing) {
        sessions.put(id, session);
        if (existing == null) {
            eventPublisher.publishEvent(new SessionCreatedEvent(session));
        }
    }
    return CompletableFuture.completedFuture(session);
}
Also used : SessionCreatedEvent(io.micronaut.session.event.SessionCreatedEvent)

Aggregations

SessionCreatedEvent (io.micronaut.session.event.SessionCreatedEvent)1