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,org.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>
public class ReactiveMongoSessionRepository
extends Object
implements org.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean
A
ReactiveSessionRepository implementation that uses Spring Data MongoDB.- Since:
- 2.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default collection name for storing session.static final intDeprecated. -
Constructor Summary
ConstructorsConstructorDescriptionReactiveMongoSessionRepository(org.springframework.data.mongodb.core.ReactiveMongoOperations mongoOperations) -
Method Summary
Modifier and TypeMethodDescriptionvoidDo not useReactiveIndexOperationsto ensure indexes exist.reactor.core.publisher.Mono<org.springframework.session.data.mongo.MongoSession>Creates a newMongoSessionthat is capable of being persisted by thisReactiveSessionRepository.reactor.core.publisher.Mono<Void>deleteById(String id) reactor.core.publisher.Mono<org.springframework.session.data.mongo.MongoSession>reactor.core.publisher.Mono<Void>save(org.springframework.session.data.mongo.MongoSession session) voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) voidsetBlockingMongoOperations(org.springframework.data.mongodb.core.MongoOperations blockingMongoOperations) voidsetCollectionName(String collectionName) voidsetDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.voidsetMaxInactiveIntervalInSeconds(Integer defaultMaxInactiveInterval) Deprecated.since 3.0.0, in favor ofsetDefaultMaxInactiveInterval(Duration)voidsetMongoSessionConverter(AbstractMongoSessionConverter mongoSessionConverter)
-
Field Details
-
DEFAULT_INACTIVE_INTERVAL
Deprecated.since 3.0.0 in favor ofMapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDSThe 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
public reactor.core.publisher.Mono<org.springframework.session.data.mongo.MongoSession> createSession()Creates a newMongoSessionthat is capable of being persisted by thisReactiveSessionRepository.This allows optimizations and customizations in how the
MongoSessionis 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:
createSessionin interfaceorg.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>- Returns:
- a new
MongoSessionthat is capable of being persisted by thisReactiveSessionRepository
-
save
public reactor.core.publisher.Mono<Void> save(org.springframework.session.data.mongo.MongoSession session) - Specified by:
savein interfaceorg.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>
-
findById
public reactor.core.publisher.Mono<org.springframework.session.data.mongo.MongoSession> findById(String id) - Specified by:
findByIdin interfaceorg.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>
-
deleteById
- Specified by:
deleteByIdin interfaceorg.springframework.session.ReactiveSessionRepository<org.springframework.session.data.mongo.MongoSession>
-
afterPropertiesSet
public void afterPropertiesSet()Do not useReactiveIndexOperationsto ensure indexes exist. Instead, get a blockingIndexOperationsand use that instead, if possible.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) - Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
setDefaultMaxInactiveInterval
Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never time out. The default is 30 minutes.- Parameters:
defaultMaxInactiveInterval- the default maxInactiveInterval
-
setMaxInactiveIntervalInSeconds
@Deprecated(since="3.0.0") public void setMaxInactiveIntervalInSeconds(Integer defaultMaxInactiveInterval) Deprecated.since 3.0.0, in favor ofsetDefaultMaxInactiveInterval(Duration)Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never time out. The default is 1800 (30 minutes).- Parameters:
defaultMaxInactiveInterval- the default maxInactiveInterval in seconds
-
getCollectionName
-
setCollectionName
-
setMongoSessionConverter
-
setBlockingMongoOperations
public void setBlockingMongoOperations(org.springframework.data.mongodb.core.MongoOperations blockingMongoOperations)
-
MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS