public interface CacheAwareContextLoaderDelegateCacheAwareContextLoaderDelegate は、アプリケーションコンテキストのロードとクローズを担当し、バックグラウンドで ContextCache と透過的に対話します。 メモ: CacheAwareContextLoaderDelegate は、ContextLoader または SmartContextLoader インターフェースを継承しません。
| 修飾子と型 | フィールドと説明 |
|---|---|
static StringSE | DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME デフォルトの CacheAwareContextLoaderDelegate の完全修飾クラス名を構成するために使用されるシステムプロパティ。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | closeContext(MergedContextConfiguration mergedContextConfiguration, DirtiesContext.HierarchyMode hierarchyMode) 提供された MergedContextConfiguration のアプリケーションコンテキストを ContextCache から削除し、それが ConfigurableApplicationContext のインスタンスである場合は閉じます。 |
default boolean | isContextLoaded(MergedContextConfiguration mergedContextConfiguration) |
ApplicationContext | loadContext(MergedContextConfiguration mergedContextConfiguration) 指定された MergedContextConfiguration で構成された ContextLoader に委譲することにより、提供された MergedContextConfiguration のアプリケーションコンテキストをロードします。 |
static final StringSE DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_PROPERTY_NAME
CacheAwareContextLoaderDelegate の完全修飾クラス名を構成するために使用されるシステムプロパティ。 あるいは、SpringProperties メカニズムを介して構成することもできます。
このプロパティが定義されていない場合、DefaultCacheAwareContextLoaderDelegate がデフォルトとして使用されます。
default boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration)
MergedContextConfiguration のアプリケーションコンテキストがロードされている(つまり、ContextCache に存在する)かどうかを判別します。 このメソッドの実装は、副作用としてアプリケーションコンテキストをロードしてはなりません。さらに、このメソッドの実装は ContextCache.logStatistics() を介してキャッシュ統計を記録するべきではありません。
このメソッドのデフォルト実装は、常に false を返します。カスタム CacheAwareContextLoaderDelegate 実装では、このメソッドをより意味のある実装でオーバーライドすることを強くお勧めします。Spring の標準 CacheAwareContextLoaderDelegate 実装がこのメソッドを適切にオーバーライドすることに注意してください。
mergedContextConfiguration - アプリケーションコンテキストのロードに使用されるマージされたコンテキスト構成。非 nulltrue (アプリケーションコンテキストがロードされている場合)loadContext(org.springframework.test.context.MergedContextConfiguration), closeContext(org.springframework.test.context.MergedContextConfiguration, org.springframework.test.annotation.DirtiesContext.HierarchyMode)ApplicationContext loadContext(MergedContextConfiguration mergedContextConfiguration)
MergedContextConfiguration で構成された ContextLoader に委譲することにより、提供された MergedContextConfiguration のアプリケーションコンテキストをロードします。ContextCache にコンテキストが存在する場合は、単に返されます。それ以外の場合は、ロードされてキャッシュに保存され、返されます。
キャッシュ統計は、ContextCache.logStatistics() を呼び出して記録する必要があります。
mergedContextConfiguration - アプリケーションコンテキストのロードに使用するマージされたコンテキスト構成。非 nullnull)IllegalStateExceptionSE - アプリケーションコンテキストの取得中または読み込み中にエラーが発生した場合 isContextLoaded(org.springframework.test.context.MergedContextConfiguration), closeContext(org.springframework.test.context.MergedContextConfiguration, org.springframework.test.annotation.DirtiesContext.HierarchyMode)void closeContext(MergedContextConfiguration mergedContextConfiguration, @Nullable DirtiesContext.HierarchyMode hierarchyMode)
MergedContextConfiguration のアプリケーションコンテキストを ContextCache から削除し、それが ConfigurableApplicationContext のインスタンスである場合は閉じます。 コンテキストをキャッシュから削除するときは、提供された HierarchyMode のセマンティクスを順守する必要があります。詳細については、DirtiesContext.HierarchyMode の Javadoc を参照してください。
一般的に、このメソッドはシングルトン Bean の状態が変更された場合(コンテキストとの将来の対話に影響する可能性がある場合)、またはコンテキストをキャッシュから時期尚早に削除する必要がある場合にのみ呼び出す必要があります。
mergedContextConfiguration - クローズするアプリケーションコンテキストのマージされたコンテキスト構成。非 nullhierarchyMode - 階層モード。コンテキストが階層の一部ではない場合、null である可能性があります isContextLoaded(org.springframework.test.context.MergedContextConfiguration), loadContext(org.springframework.test.context.MergedContextConfiguration)