Class AbstractMongoSessionConverter

java.lang.Object
org.springframework.session.data.mongo.AbstractMongoSessionConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.GenericConverter
Direct Known Subclasses:
JacksonMongoSessionConverter, JdkMongoSessionConverter

public abstract class AbstractMongoSessionConverter extends Object implements org.springframework.core.convert.converter.GenericConverter
Base class for serializing and deserializing session objects. To create custom serializer you have to implement this interface and simply register your class as a bean.
Since:
1.2
  • Constructor Details

    • AbstractMongoSessionConverter

      public AbstractMongoSessionConverter()
  • Method Details

    • getQueryForIndex

      @Nullable protected abstract org.springframework.data.mongodb.core.query.Query getQueryForIndex(String indexName, Object indexValue)
      Returns query to be executed to return sessions based on a particular index.
      Parameters:
      indexName - name of the index
      indexValue - value to query against
      Returns:
      built query or null if indexName is not supported
    • ensureIndexes

      protected void ensureIndexes(org.springframework.data.mongodb.core.index.IndexOperations sessionCollectionIndexes)
      Method ensures that there is a TTL index on expireAt field. It's has expireAfterSeconds set to zero seconds, so the expiration time is controlled by the application. It can be extended in custom converters when there is a need for creating additional custom indexes.
      Parameters:
      sessionCollectionIndexes - IndexOperations to use
    • extractPrincipal

      protected String extractPrincipal(MongoSession expiringSession)
    • getConvertibleTypes

      public Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair> getConvertibleTypes()
      Specified by:
      getConvertibleTypes in interface org.springframework.core.convert.converter.GenericConverter
    • convert

      @Nullable public Object convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
      Specified by:
      convert in interface org.springframework.core.convert.converter.GenericConverter
    • convert

      protected abstract com.mongodb.DBObject convert(MongoSession session)
    • convert

      protected abstract MongoSession convert(org.bson.Document sessionWrapper)
    • setIndexResolver

      public void setIndexResolver(IndexResolver<MongoSession> indexResolver)