public class DefaultCacheAwareContextLoaderDelegate extends ObjectSE implements CacheAwareContextLoaderDelegate
CacheAwareContextLoaderDelegate
インターフェースのデフォルト実装。 静的 DefaultContextCache
を使用するには、DefaultCacheAwareContextLoaderDelegate()
コンストラクターを呼び出します。それ以外の場合は、DefaultCacheAwareContextLoaderDelegate(ContextCache)
を呼び出して、カスタム ContextCache
実装を提供します。
コンストラクターと説明 |
---|
DefaultCacheAwareContextLoaderDelegate() 静的 DefaultContextCache を使用して新しい DefaultCacheAwareContextLoaderDelegate を構築します。 |
DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache) 提供された ContextCache を使用して新しい DefaultCacheAwareContextLoaderDelegate を構築します。 |
修飾子と型 | メソッドと説明 |
---|---|
void | closeContext(MergedContextConfiguration mergedContextConfiguration, DirtiesContext.HierarchyMode hierarchyMode) 提供された MergedContextConfiguration のアプリケーションコンテキストを ContextCache から削除し、それが ConfigurableApplicationContext のインスタンスである場合は閉じます。 |
protected ContextCache | getContextCache() このコンテキストローダーデリゲートによって使用される ContextCache を取得します。 |
ApplicationContext | loadContext(MergedContextConfiguration mergedContextConfiguration) 指定された MergedContextConfiguration で構成された ContextLoader に委譲することにより、提供された MergedContextConfiguration のアプリケーションコンテキストをロードします。 |
protected ApplicationContext | loadContextInternal(MergedContextConfiguration mergedContextConfiguration) 提供されたマージされたコンテキスト構成の ApplicationContext をロードします。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public DefaultCacheAwareContextLoaderDelegate()
DefaultContextCache
を使用して新しい DefaultCacheAwareContextLoaderDelegate
を構築します。このデフォルトのキャッシュは静的なので、同じ JVM プロセス内で同じ一意のコンテキスト構成を宣言する後続のすべてのテストで、各コンテキストをキャッシュして再利用できます。
public DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache)
ContextCache
を使用して新しい DefaultCacheAwareContextLoaderDelegate
を構築します。protected ContextCache getContextCache()
ContextCache
を取得します。protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration) throws ExceptionSE
ApplicationContext
をロードします。SmartContextLoader
および ContextLoader
SPI の両方をサポートします。
ExceptionSE
- アプリケーションコンテキストのロード中にエラーが発生した場合 public ApplicationContext loadContext(MergedContextConfiguration mergedContextConfiguration)
CacheAwareContextLoaderDelegate
MergedContextConfiguration
で構成された ContextLoader
に委譲することにより、提供された MergedContextConfiguration
のアプリケーションコンテキストをロードします。ContextCache
にコンテキストが存在する場合は、単に返されます。それ以外の場合は、ロードされてキャッシュに保存され、返されます。
キャッシュ統計は、ContextCache.logStatistics()
を呼び出して記録する必要があります。
CacheAwareContextLoaderDelegate
の loadContext
mergedContextConfiguration
- アプリケーションコンテキストのロードに使用するマージされたコンテキスト構成。非 null
public void closeContext(MergedContextConfiguration mergedContextConfiguration, @Nullable DirtiesContext.HierarchyMode hierarchyMode)
CacheAwareContextLoaderDelegate
MergedContextConfiguration
のアプリケーションコンテキストを ContextCache
から削除し、それが ConfigurableApplicationContext
のインスタンスである場合は閉じます。 コンテキストをキャッシュから削除するときは、提供された HierarchyMode
のセマンティクスを順守する必要があります。詳細については、DirtiesContext.HierarchyMode
の Javadoc を参照してください。
一般的に、このメソッドはシングルトン Bean の状態が変更された場合(コンテキストとの将来の対話に影響する可能性がある場合)、またはコンテキストをキャッシュから時期尚早に削除する必要がある場合にのみ呼び出す必要があります。
CacheAwareContextLoaderDelegate
の closeContext
mergedContextConfiguration
- クローズするアプリケーションコンテキストのマージされたコンテキスト構成。非 null
hierarchyMode
- 階層モード。コンテキストが階層の一部ではない場合、null
である可能性があります