接口 CacheAwareContextLoaderDelegate
public interface CacheAwareContextLoaderDelegate
ACacheAwareContextLoaderDelegate
is responsible for loading and closing application contexts, interacting transparently with aContextCache
behind the scenes.Note:
CacheAwareContextLoaderDelegate
does not extend theContextLoader
orSmartContextLoader
interface.- 从以下版本开始:
- 3.2.2
- 作者:
- Sam Brannen
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
closeContext(MergedContextConfiguration mergedContextConfiguration, DirtiesContext.HierarchyMode hierarchyMode)
Remove the application context for the suppliedMergedContextConfiguration
from theContextCache
and close it if it is an instance ofConfigurableApplicationContext
.ApplicationContext
loadContext(MergedContextConfiguration mergedContextConfiguration)
Load the application context for the suppliedMergedContextConfiguration
by delegating to theContextLoader
configured in the givenMergedContextConfiguration
.
方法详细资料
loadContext
ApplicationContext loadContext(MergedContextConfiguration mergedContextConfiguration)
Load the application context for the suppliedMergedContextConfiguration
by delegating to theContextLoader
configured in the givenMergedContextConfiguration
.If the context is present in the
ContextCache
it will simply be returned; otherwise, it will be loaded, stored in the cache, and returned.The cache statistics should be logged by invoking
ContextCache.logStatistics()
.- 参数:
mergedContextConfiguration
- the merged context configuration to use to load the application context; nevernull
- 返回:
- the application context
- 抛出:
IllegalStateException
- if an error occurs while retrieving or loading the application context
closeContext
void closeContext(MergedContextConfiguration mergedContextConfiguration, DirtiesContext.HierarchyMode hierarchyMode)
Remove the application context for the suppliedMergedContextConfiguration
from theContextCache
and close it if it is an instance ofConfigurableApplicationContext
.The semantics of the supplied
HierarchyMode
must be honored when removing the context from the cache. See the Javadoc forDirtiesContext.HierarchyMode
for details.Generally speaking, this method should only be called if the state of a singleton bean has been changed (potentially affecting future interaction with the context) or if the context needs to be prematurely removed from the cache.
- 参数:
mergedContextConfiguration
- the merged context configuration for the application context to close; nevernull
hierarchyMode
- the hierarchy mode; may benull
if the context is not part of a hierarchy- 从以下版本开始:
- 4.1