クラス 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 イベントを発行します。- entryAdded -
SessionCreatedEvent - entryEvicted -
SessionExpiredEvent - entryRemoved -
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インスタンスを作成します。方法の概要
修飾子と型メソッド説明voidorg.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSessionこのSessionRepositoryによって永続化できる新しいSessionを作成します。voiddeleteById(StringSE id) voiddestroy()voidentryAdded(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) voidentryEvicted(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) voidentryExpired(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) voidentryRemoved(com.hazelcast.core.EntryEvent<StringSE, MapSession> event) org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSessionMapSE<StringSE,org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession> findByIndexNameAndIndexValue(StringSE indexName, StringSE indexValue) voidsave(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession session) SessionRepository.createSession()によって作成されたSessionが確実に保存されます。voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) session eventsの公開に使用されるApplicationEventPublisherを設定します。voidsetDefaultMaxInactiveInterval(IntegerSE defaultMaxInactiveInterval) 使用すべきではありません。voidsetDefaultMaxInactiveInterval(DurationSE defaultMaxInactiveInterval) 新しく作成されたセッションが無効になるまでのリクエスト間の最大非アクティブ間隔を秒単位で設定します。voidsetFlushMode(FlushMode flushMode) Hazelcast フラッシュモードを設定します。voidsetIndexResolver(IndexResolver<Session> indexResolver) 使用するIndexResolverを設定します。voidsetSaveMode(SaveMode saveMode) 保存モードを設定します。voidsetSessionIdGenerator(SessionIdGenerator sessionIdGenerator) セッション ID の生成に使用するSessionIdGeneratorを設定します。voidsetSessionMapName(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) インターフェースからコピーされた説明:SessionRepositorySessionRepository.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)を推奨