int modelCount = 2;
elementBuilder.setDefaultCachingListenerElementBuilders( listenerCount );
// expectations for cache key generator.
RuntimeBeanReference cacheKeyGenerator = expectCacheKeyGeneratorParsing();
// expectations for parsing caching listeners.
List cachingListeners = new ArrayList();
for ( int i = 0; i < listenerCount; i++ )
{
String refId = elementBuilder.cachingListenerElementBuilders[i].refId;
registry.registerBeanDefinition( refId, new RootBeanDefinition( CachingListener.class ) );
Element cachingListenerElement = elementBuilder.cachingListenerElementBuilders[i].toXml();
// parse caching listener element
beanReferenceParser.parse( cachingListenerElement, parserContext, true );
RuntimeBeanReference cachingListenerReference = new RuntimeBeanReference( refId );
beanReferenceParserControl.setReturnValue( cachingListenerReference );
// validate the caching listener
validator.validate( cachingListenerReference, i, parserContext );
cachingListeners.add( cachingListenerReference );
}
registerCacheProviderFacadeDefinition();
// expectations for parsing cache models.
elementBuilder.setDefaultCachingModelElementBuilders( modelCount );
elementBuilder.setDefaultFlushingModelElementBuilders( modelCount );
Map cachingModelMap = expectCachingModelParsing();
Map flushingModelMap = expectFlushingModelParsing();
Element element = elementBuilder.toXml();
CacheSetupStrategyPropertySource propertySource =
new CacheSetupStrategyPropertySource( cacheKeyGenerator,
new RuntimeBeanReference( elementBuilder.cacheProviderId ),
cachingListeners, cachingModelMap, flushingModelMap );
strategyParser.parseCacheSetupStrategy( element, parserContext, propertySource );
strategyParserControl.setMatcher( new CacheSetupStrategyPropertySourceMatcher() );