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>

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 Details

  • Constructor Details

    • ReactiveMongoSessionRepository

      public ReactiveMongoSessionRepository(org.springframework.data.mongodb.core.ReactiveMongoOperations mongoOperations)
  • Method Details

    • createSession

      public reactor.core.publisher.Mono<MongoSession> createSession()
      Creates a new MongoSession that is capable of being persisted by this ReactiveSessionRepository.

      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 interface ReactiveSessionRepository<MongoSession>
      Returns:
      a new MongoSession that is capable of being persisted by this ReactiveSessionRepository
    • save

      public reactor.core.publisher.Mono<Void> save(MongoSession session)
      Description copied from interface: ReactiveSessionRepository
      Ensures the Session created by ReactiveSessionRepository.createSession() is saved.

      Some implementations may choose to save as the Session is updated by returning a Session that immediately persists any changes. In this case, this method may not actually do anything.

      Specified by:
      save in interface ReactiveSessionRepository<MongoSession>
      Parameters:
      session - the Session to save
      Returns:
      indicator of operation completion
    • findById

      public reactor.core.publisher.Mono<MongoSession> findById(String id)
      Description copied from interface: ReactiveSessionRepository
      Gets the Session by the Session.getId() or null if no Session is found.
      Specified by:
      findById in interface ReactiveSessionRepository<MongoSession>
      Parameters:
      id - the Session.getId() to lookup
      Returns:
      the Session by the Session.getId() or null if no Session is found.
    • deleteById

      public reactor.core.publisher.Mono<Void> deleteById(String id)
      Description copied from interface: ReactiveSessionRepository
      Deletes the Session with the given Session.getId() or does nothing if the Session is not found.
      Specified by:
      deleteById in interface ReactiveSessionRepository<MongoSession>
      Parameters:
      id - the Session.getId() to delete
      Returns:
      indicator of operation completion
    • afterPropertiesSet

      public void afterPropertiesSet()
      Do not use ReactiveIndexOperations to ensure indexes exist. Instead, get a blocking IndexOperations and use that instead, if possible.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • setDefaultMaxInactiveInterval

      public void setDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval)
      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.
      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

      public String getCollectionName()
    • setCollectionName

      public void setCollectionName(String collectionName)
    • setMongoSessionConverter

      public void setMongoSessionConverter(AbstractMongoSessionConverter mongoSessionConverter)
    • setBlockingMongoOperations

      public void setBlockingMongoOperations(org.springframework.data.mongodb.core.MongoOperations blockingMongoOperations)
    • setSessionIdGenerator

      public void setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)