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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.core.convert.converter.GenericConverter
org.springframework.core.convert.converter.GenericConverter.ConvertiblePair
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType) protected abstract MongoSession
convert
(org.bson.Document sessionWrapper) protected abstract com.mongodb.DBObject
convert
(MongoSession session) protected void
ensureIndexes
(org.springframework.data.mongodb.core.index.IndexOperations sessionCollectionIndexes) Method ensures that there is a TTL index on expireAt field.protected String
extractPrincipal
(MongoSession expiringSession) Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair>
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.void
setIndexResolver
(IndexResolver<Session> indexResolver)
-
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 indexindexValue
- 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
-
getConvertibleTypes
public Set<org.springframework.core.convert.converter.GenericConverter.ConvertiblePair> getConvertibleTypes()- Specified by:
getConvertibleTypes
in interfaceorg.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 interfaceorg.springframework.core.convert.converter.GenericConverter
-
convert
-
convert
-
setIndexResolver
-