クラス MongoIndexedSessionRepository
java.lang.ObjectSE
org.springframework.session.data.mongo.MongoIndexedSessionRepository
- 実装済みのインターフェース一覧:
org.springframework.beans.factory.Aware、org.springframework.beans.factory.InitializingBean、org.springframework.context.ApplicationEventPublisherAware、FindByIndexNameSessionRepository<MongoSession>、SessionRepository<MongoSession>
public class MongoIndexedSessionRepository
extends ObjectSE
implements FindByIndexNameSessionRepository<MongoSession>, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.InitializingBean
Mongo にセッションを格納するセッションリポジトリの実装。
AbstractMongoSessionConverter を使用して、セッションオブジェクトをネイティブ Mongo 表現(DBObject)との間で変換します。リポジトリは、データベースから期限切れのセッションを削除するロールも果たします。クリーンアップは毎分行われます。- 導入:
- 2.2.0
フィールド概要
フィールドインターフェース org.springframework.session.FindByIndexNameSessionRepository から継承されたフィールド
PRINCIPAL_NAME_INDEX_NAMEコンストラクター概要
コンストラクターコンストラクター説明MongoIndexedSessionRepository(org.springframework.data.mongodb.core.MongoOperations mongoOperations) 方法の概要
修飾子と型メソッド説明voidこのSessionRepositoryによって永続化できる新しいSessionを作成します。voiddeleteById(StringSE id) findByIndexNameAndIndexValue(StringSE indexName, StringSE indexValue) 現在、このリポジトリでは、PRINCIPAL_NAME_INDEX_NAMEに対するクエリのみが許可されています。voidsave(MongoSession session) SessionRepository.createSession()によって作成されたSessionが確実に保存されます。voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) voidsetCollectionName(StringSE collectionName) voidsetDefaultMaxInactiveInterval(DurationSE defaultMaxInactiveInterval) 新しく作成されたセッションが無効になるまでのリクエスト間の最大非アクティブ間隔を秒単位で設定します。voidsetMaxInactiveIntervalInSeconds(IntegerSE defaultMaxInactiveInterval) 使用すべきではありません。3.0.0 以降、setDefaultMaxInactiveInterval(Duration)を推奨voidsetMongoSessionConverter(AbstractMongoSessionConverter mongoSessionConverter) voidsetSessionIdGenerator(SessionIdGenerator sessionIdGenerator) セッション ID の生成に使用するSessionIdGeneratorを設定します。クラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース org.springframework.session.FindByIndexNameSessionRepository から継承されたメソッド
findByPrincipalName
フィールドの詳細
DEFAULT_INACTIVE_INTERVAL
使用すべきではありません。3.0.0 以降、MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDSを推奨セッションが期限切れになるデフォルトの時間(秒単位)。- 関連事項:
DEFAULT_COLLECTION_NAME
セッションを保存するためのデフォルトのコレクション名。- 関連事項:
コンストラクターの詳細
MongoIndexedSessionRepository
public MongoIndexedSessionRepository(org.springframework.data.mongodb.core.MongoOperations mongoOperations)
方法の詳細
createSession
インターフェースからコピーされた説明:SessionRepositoryこのSessionRepositoryによって永続化できる新しいSessionを作成します。これにより、
Sessionの永続化方法の最適化とカスタマイズが可能になります。例: 返された実装は変更を追跡し、保存時にデルタのみを永続化する必要があることを保証する場合があります。- 次で指定:
- インターフェース
SessionRepository<MongoSession>内のcreateSession - 戻り値:
- この
SessionRepositoryによって永続化できる新しいSession
save
インターフェースからコピーされた説明:SessionRepositorySessionRepository.createSession()によって作成されたSessionが確実に保存されます。一部の実装では、変更を即座に保持する
Sessionを返すことにより、Sessionが更新されたときに保存することを選択する場合があります。この場合、このメソッドは実際には何も実行しない可能性があります。- 次で指定:
- インターフェース
SessionRepository<MongoSession>内のsave - パラメーター:
session- 保存するSession
findById
インターフェースからコピーされた説明:SessionRepository- 次で指定:
- インターフェース
SessionRepository<MongoSession>内のfindById - パラメーター:
id- ルックアップするSession.getId()- 戻り値:
Session.getId()によるSession、またはSessionが見つからない場合は null。
findByIndexNameAndIndexValue
public MapSE<StringSE,MongoSession> findByIndexNameAndIndexValue(StringSE indexName, StringSE indexValue) 現在、このリポジトリでは、PRINCIPAL_NAME_INDEX_NAMEに対するクエリのみが許可されています。- 次で指定:
- インターフェース
FindByIndexNameSessionRepository<MongoSession>内のfindByIndexNameAndIndexValue - パラメーター:
indexName- インデックスの場合の名前 (i.e.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)indexValue- 検索するインデックスの値。- 戻り値:
- セッションマップ
deleteById
インターフェースからコピーされた説明:SessionRepository- 次で指定:
- インターフェース
SessionRepository<MongoSession>内のdeleteById - パラメーター:
id- 削除するSession.getId()
afterPropertiesSet
public void afterPropertiesSet()- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean内のafterPropertiesSet
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) - 次で指定:
- インターフェース
org.springframework.context.ApplicationEventPublisherAware内のsetApplicationEventPublisher
setDefaultMaxInactiveInterval
新しく作成されたセッションが無効になるまでの、リクエスト間の最大非アクティブ間隔を秒単位で設定します。負の時間は、セッションがタイムアウトしないことを示します。デフォルトは 30 分です。- パラメーター:
defaultMaxInactiveInterval- デフォルトの maxInactiveInterval
setMaxInactiveIntervalInSeconds
@DeprecatedSE(since="3.0.0") public void setMaxInactiveIntervalInSeconds(IntegerSE defaultMaxInactiveInterval) 使用すべきではありません。3.0.0 以降、setDefaultMaxInactiveInterval(Duration)を推奨新しく作成されたセッションが無効になるまでの、リクエスト間の最大非アクティブ間隔を秒単位で設定します。負の時間は、セッションがタイムアウトしないことを示します。デフォルトは 1800 (30 分です)。- パラメーター:
defaultMaxInactiveInterval- デフォルトの maxInactiveInterval(秒単位)
setCollectionName
setMongoSessionConverter
setSessionIdGenerator
セッション ID の生成に使用するSessionIdGeneratorを設定します。- パラメーター:
sessionIdGenerator- 使用するSessionIdGenerator- 導入:
- 3.2
MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDSを推奨