Class ReactiveMongoSessionRepository
java.lang.Object
org.springframework.session.data.mongo.ReactiveMongoSessionRepository
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationEventPublisherAware
,ReactiveSessionRepository<MongoSession>
- Direct Known Subclasses:
ReactiveMongoOperationsSessionRepository
public class ReactiveMongoSessionRepository
extends Object
implements ReactiveSessionRepository<MongoSession>, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean
A
ReactiveSessionRepository
implementation that uses Spring Data MongoDB.- Since:
- 2.2.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default collection name for storing session.static final int
The default time period in seconds in which a session will expire. -
Constructor Summary
ConstructorDescriptionReactiveMongoSessionRepository
(org.springframework.data.mongodb.core.ReactiveMongoOperations mongoOperations) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Do not useReactiveIndexOperations
to ensure indexes exist.reactor.core.publisher.Mono<MongoSession>
Creates a newMongoSession
that is capable of being persisted by thisReactiveSessionRepository
.reactor.core.publisher.Mono<Void>
deleteById
(String id) reactor.core.publisher.Mono<MongoSession>
reactor.core.publisher.Mono<Void>
save
(MongoSession session) Ensures theSession
created byReactiveSessionRepository.createSession()
is saved.void
setApplicationEventPublisher
(org.springframework.context.ApplicationEventPublisher eventPublisher) void
setBlockingMongoOperations
(org.springframework.data.mongodb.core.MongoOperations blockingMongoOperations) void
setCollectionName
(String collectionName) void
setMaxInactiveIntervalInSeconds
(Integer maxInactiveIntervalInSeconds) void
setMongoSessionConverter
(AbstractMongoSessionConverter mongoSessionConverter)
-
Field Details
-
DEFAULT_INACTIVE_INTERVAL
public static final int DEFAULT_INACTIVE_INTERVALThe default time period in seconds in which a session will expire.- See Also:
-
DEFAULT_COLLECTION_NAME
The default collection name for storing session.- See Also:
-
-
Constructor Details
-
ReactiveMongoSessionRepository
public ReactiveMongoSessionRepository(org.springframework.data.mongodb.core.ReactiveMongoOperations mongoOperations)
-
-
Method Details
-
createSession
Creates a newMongoSession
that is capable of being persisted by thisReactiveSessionRepository
.This allows optimizations and customizations in how the
MongoSession
is persisted. For example, the implementation returned might keep track of the changes ensuring that only the delta needs to be persisted on a save.- Specified by:
createSession
in interfaceReactiveSessionRepository<MongoSession>
- Returns:
- a new
MongoSession
that is capable of being persisted by thisReactiveSessionRepository
-
save
Description copied from interface:ReactiveSessionRepository
Ensures theSession
created byReactiveSessionRepository.createSession()
is saved.Some implementations may choose to save as the
Session
is updated by returning aSession
that immediately persists any changes. In this case, this method may not actually do anything.- Specified by:
save
in interfaceReactiveSessionRepository<MongoSession>
- Parameters:
session
- theSession
to save- Returns:
- indicator of operation completion
-
findById
Description copied from interface:ReactiveSessionRepository
- Specified by:
findById
in interfaceReactiveSessionRepository<MongoSession>
- Parameters:
id
- theSession.getId()
to lookup- Returns:
- the
Session
by theSession.getId()
or null if noSession
is found.
-
deleteById
Description copied from interface:ReactiveSessionRepository
- Specified by:
deleteById
in interfaceReactiveSessionRepository<MongoSession>
- Parameters:
id
- theSession.getId()
to delete- Returns:
- indicator of operation completion
-
afterPropertiesSet
public void afterPropertiesSet()Do not useReactiveIndexOperations
to ensure indexes exist. Instead, get a blockingIndexOperations
and use that instead, if possible.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) - Specified by:
setApplicationEventPublisher
in interfaceorg.springframework.context.ApplicationEventPublisherAware
-
getMaxInactiveIntervalInSeconds
-
setMaxInactiveIntervalInSeconds
-
getCollectionName
-
setCollectionName
-
setMongoSessionConverter
-
setBlockingMongoOperations
public void setBlockingMongoOperations(org.springframework.data.mongodb.core.MongoOperations blockingMongoOperations)
-