クラス HazelcastIndexedSessionRepository
java.lang.ObjectSE
org.springframework.session.hazelcast.HazelcastIndexedSessionRepository
- 実装されたすべてのインターフェース:
com.hazelcast.map.listener.EntryAddedListener<StringSE,
、MapSession> com.hazelcast.map.listener.EntryEvictedListener<StringSE,
、MapSession> com.hazelcast.map.listener.EntryExpiredListener<StringSE,
、MapSession> com.hazelcast.map.listener.EntryRemovedListener<StringSE,
、MapSession> com.hazelcast.map.listener.MapListener
、EventListenerSE
、org.springframework.beans.factory.DisposableBean
、org.springframework.beans.factory.InitializingBean
、FindByIndexNameSessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
、SessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
public class HazelcastIndexedSessionRepository
extends ObjectSE
implements FindByIndexNameSessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>, com.hazelcast.map.listener.EntryAddedListener<StringSE,MapSession>, com.hazelcast.map.listener.EntryEvictedListener<StringSE,MapSession>, com.hazelcast.map.listener.EntryRemovedListener<StringSE,MapSession>, com.hazelcast.map.listener.EntryExpiredListener<StringSE,MapSession>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Hazelcast の分散
IMap
にセッションを格納する SessionRepository
実装。新しいインスタンスを作成する方法の例を以下に示します。
Config config = new Config(); // ... configure Hazelcast ... HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config); HazelcastIndexedSessionRepository sessionRepository = new HazelcastIndexedSessionRepository(hazelcastInstance);
findByIndexNameAndIndexValue(String, String)
メソッドを使用したプリンシパル名によるセッションの検索をサポートするには、この実装に提供される IMap
のカスタム構成が必要です。次のスニペットは、プログラムによる Hazelcast 構成を使用して必要な構成を定義する方法を示しています。AttributeConfig attributeConfig = new AttributeConfig() .setName(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE) .setExtractorClassName(rincipalNameExtractor.class.getName()); Config config = new Config(); config.getMapConfig(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME) .addAttributeConfig(attributeConfig) .addIndexConfig(new IndexConfig( IndexType.HASH, HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)); Hazelcast.newHazelcastInstance(config);この実装は、Hazelcast が支援する SessionRepository のイベントをリッスンし、それらのイベントを対応する Spring Session イベントに変換します。指定された
ApplicationEventPublisher
で Spring Session イベントを発行します。- エントリ追加しました -
SessionCreatedEvent
- エントリ追放 -
SessionExpiredEvent
- エントリ削除済み -
SessionDeletedEvent
- 導入:
- 2.2.0
フィールドサマリー
フィールド修飾子と型フィールド説明static final StringSE
セッションを保存するために Spring Session が使用するマップのデフォルト名。static final StringSE
プリンシパル名のカスタム属性名。インターフェース org.springframework.session.FindByIndexNameSessionRepository から継承されたフィールド
PRINCIPAL_NAME_INDEX_NAME
コンストラクターのサマリー
コンストラクターコンストラクター説明HazelcastIndexedSessionRepository
(com.hazelcast.core.HazelcastInstance hazelcastInstance) 新しいHazelcastIndexedSessionRepository
インスタンスを作成します。メソッドのサマリー
修飾子と型メソッド説明void
org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession
このSessionRepository
によって永続化できる新しいSession
を作成します。void
deleteById
(StringSE id) void
destroy()
void
entryAdded
(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) void
entryEvicted
(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) void
entryExpired
(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) void
entryRemoved
(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession
MapSE<StringSE,
org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession> findByIndexNameAndIndexValue
(StringSE indexName, StringSE indexValue) void
save
(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession session) SessionRepository.createSession()
によって作成されたSession
が確実に保存されます。void
setApplicationEventPublisher
(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) session events
の公開に使用されるApplicationEventPublisher
を設定します。void
setDefaultMaxInactiveInterval
(IntegerSE defaultMaxInactiveInterval) 使用すべきではありません。void
setDefaultMaxInactiveInterval
(DurationSE defaultMaxInactiveInterval) 新しく作成されたセッションが無効になるまでのリクエスト間の最大非アクティブ間隔を秒単位で設定します。void
setFlushMode
(FlushMode flushMode) Hazelcast フラッシュモードを設定します。void
setIndexResolver
(IndexResolver<Session> indexResolver) 使用するIndexResolver
を設定します。void
setSaveMode
(SaveMode saveMode) 保存モードを設定します。void
setSessionIdGenerator
(SessionIdGenerator sessionIdGenerator) セッション ID の生成に使用するSessionIdGenerator
を設定します。void
setSessionMapName
(StringSE sessionMapName) セッションの保存に使用するマップの名前を設定します。クラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
インターフェース org.springframework.session.FindByIndexNameSessionRepository から継承されたメソッド
findByPrincipalName
フィールドの詳細
コンストラクターの詳細
HazelcastIndexedSessionRepository
public HazelcastIndexedSessionRepository(com.hazelcast.core.HazelcastInstance hazelcastInstance) 新しいHazelcastIndexedSessionRepository
インスタンスを作成します。- パラメーター:
hazelcastInstance
- セッションの管理に使用するHazelcastInstance
メソッドの詳細
afterPropertiesSet
public void afterPropertiesSet()- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean
のafterPropertiesSet
destroy
public void destroy()- 次で指定:
- インターフェース
org.springframework.beans.factory.DisposableBean
のdestroy
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) session events
の公開に使用されるApplicationEventPublisher
を設定します。デフォルトでは、セッションイベントは公開されません。- パラメーター:
applicationEventPublisher
- セッションイベントの発行に使用されるApplicationEventPublisher
。null にすることはできません。
setDefaultMaxInactiveInterval
新しく作成されたセッションが無効になるまでの、リクエスト間の最大非アクティブ間隔を秒単位で設定します。負の時間は、セッションがタイムアウトしないことを示します。デフォルトは 30 分です。- パラメーター:
defaultMaxInactiveInterval
- デフォルトの maxInactiveInterval
setDefaultMaxInactiveInterval
@DeprecatedSE(since="3.0.0") public void setDefaultMaxInactiveInterval(IntegerSE defaultMaxInactiveInterval) 使用すべきではありません。3.0.0 以降、setDefaultMaxInactiveInterval(Duration)
を推奨新しく作成されたセッションが無効になるまでの、リクエスト間の最大非アクティブ間隔を秒単位で設定します。負の時間は、セッションがタイムアウトしないことを示します。デフォルトは 1800 (30 分です)。- パラメーター:
defaultMaxInactiveInterval
- 秒単位のデフォルトの maxInactiveInterval
setIndexResolver
使用するIndexResolver
を設定します。- パラメーター:
indexResolver
- インデックスリゾルバー
setSessionMapName
セッションの保存に使用するマップの名前を設定します。- パラメーター:
sessionMapName
- セッションマップ名
setFlushMode
Hazelcast フラッシュモードを設定します。デフォルトのフラッシュモードはFlushMode.ON_SAVE
です。- パラメーター:
flushMode
- 新しい Hazelcast フラッシュモード
setSaveMode
保存モードを設定します。- パラメーター:
saveMode
- 保存モード
createSession
public org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession createSession()インターフェースからコピーされた説明:SessionRepository
このSessionRepository
によって永続化できる新しいSession
を作成します。これにより、
Session
の永続化方法の最適化とカスタマイズが可能になります。例: 返された実装は変更を追跡し、保存時にデルタのみを永続化する必要があることを保証する場合があります。- 次で指定:
- インターフェース
SessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
のcreateSession
- 戻り値:
- この
SessionRepository
によって永続化できる新しいSession
save
public void save(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession session) インターフェースからコピーされた説明:SessionRepository
SessionRepository.createSession()
によって作成されたSession
が確実に保存されます。一部の実装では、変更を即座に保持する
Session
を返すことにより、Session
が更新されたときに保存することを選択する場合があります。この場合、このメソッドは実際には何も実行しない可能性があります。- 次で指定:
- インターフェース
SessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
のsave
- パラメーター:
session
- 保存するSession
findById
public org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession findById(StringSE id) インターフェースからコピーされた説明:SessionRepository
- 次で指定:
- インターフェース
SessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
のfindById
- パラメーター:
id
- ルックアップするSession.getId()
- 戻り値:
Session.getId()
によるSession
、またはSession
が見つからない場合は null。
deleteById
インターフェースからコピーされた説明:SessionRepository
- 次で指定:
- インターフェース
SessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
のdeleteById
- パラメーター:
id
- 削除するSession.getId()
findByIndexNameAndIndexValue
public MapSE<StringSE,org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession> findByIndexNameAndIndexValue(StringSE indexName, StringSE indexValue) インターフェースからコピーされた説明:FindByIndexNameSessionRepository
- 次で指定:
- インターフェース
FindByIndexNameSessionRepository<org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession>
のfindByIndexNameAndIndexValue
- パラメーター:
indexName
- インデックスの名前 (i.e.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME
)indexValue
- 検索するインデックスの値。- 戻り値:
- 指定されたインデックス名とインデックス値を含むすべてのセッションの
Session
へのセッション ID のMap
(非null
)。結果が見つからない場合は、空のMap
が返されます。
entryAdded
- 次で指定:
- インターフェース
com.hazelcast.map.listener.EntryAddedListener<StringSE,
のMapSession> entryAdded
entryEvicted
- 次で指定:
- インターフェース
com.hazelcast.map.listener.EntryEvictedListener<StringSE,
のMapSession> entryEvicted
entryRemoved
- 次で指定:
- インターフェース
com.hazelcast.map.listener.EntryRemovedListener<StringSE,
のMapSession> entryRemoved
entryExpired
- 次で指定:
- インターフェース
com.hazelcast.map.listener.EntryExpiredListener<StringSE,
のMapSession> entryExpired
setSessionIdGenerator
セッション ID の生成に使用するSessionIdGenerator
を設定します。- パラメーター:
sessionIdGenerator
- 使用するSessionIdGenerator
- 導入:
- 3.2
setDefaultMaxInactiveInterval(Duration)
を推奨