类 DefaultCacheAwareContextLoaderDelegate
- java.lang.Object
- org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate
- 所有已实现的接口:
CacheAwareContextLoaderDelegate
public class DefaultCacheAwareContextLoaderDelegate extends Object implements CacheAwareContextLoaderDelegate
Default implementation of theCacheAwareContextLoaderDelegate
interface.To use a static
DefaultContextCache
, invoke theDefaultCacheAwareContextLoaderDelegate()
constructor; otherwise, invoke theDefaultCacheAwareContextLoaderDelegate(ContextCache)
and provide a customContextCache
implementation.- 从以下版本开始:
- 4.1
- 作者:
- Sam Brannen
构造器概要
构造器 构造器 说明 DefaultCacheAwareContextLoaderDelegate()
Construct a newDefaultCacheAwareContextLoaderDelegate
using a staticDefaultContextCache
.DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache)
Construct a newDefaultCacheAwareContextLoaderDelegate
using the suppliedContextCache
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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
.protected ContextCache
getContextCache()
Get theContextCache
used by this context loader delegate.ApplicationContext
loadContext(MergedContextConfiguration mergedContextConfiguration)
Load the application context for the suppliedMergedContextConfiguration
by delegating to theContextLoader
configured in the givenMergedContextConfiguration
.protected ApplicationContext
loadContextInternal(MergedContextConfiguration mergedContextConfiguration)
Load theApplicationContext
for the supplied merged context configuration.
构造器详细资料
DefaultCacheAwareContextLoaderDelegate
public DefaultCacheAwareContextLoaderDelegate()
Construct a newDefaultCacheAwareContextLoaderDelegate
using a staticDefaultContextCache
.This default cache is static so that each context can be cached and reused for all subsequent tests that declare the same unique context configuration within the same JVM process.
DefaultCacheAwareContextLoaderDelegate
public DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache)
Construct a newDefaultCacheAwareContextLoaderDelegate
using the suppliedContextCache
.
方法详细资料
getContextCache
protected ContextCache getContextCache()
Get theContextCache
used by this context loader delegate.
loadContextInternal
protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration) throws Exception
Load theApplicationContext
for the supplied merged context configuration.Supports both the
SmartContextLoader
andContextLoader
SPIs.- 抛出:
Exception
- if an error occurs while loading the application context
loadContext
public ApplicationContext loadContext(MergedContextConfiguration mergedContextConfiguration)
从接口复制的说明:CacheAwareContextLoaderDelegate
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()
.- 指定者:
loadContext
在接口中CacheAwareContextLoaderDelegate
- 参数:
mergedContextConfiguration
- the merged context configuration to use to load the application context; nevernull
- 返回:
- the application context
closeContext
public void closeContext(MergedContextConfiguration mergedContextConfiguration, DirtiesContext.HierarchyMode hierarchyMode)
从接口复制的说明:CacheAwareContextLoaderDelegate
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.
- 指定者:
closeContext
在接口中CacheAwareContextLoaderDelegate
- 参数:
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