// if we only have a single cache loader configured in the chaining cacheloader then
// don't use a chaining cache loader at all.
// also if we are using passivation then just directly use the first cache loader.
if (clmConfig.usingChainingCacheLoader()) {
// create chaining cache loader.
ChainingCacheStore ccl = new ChainingCacheStore();
tmpLoader = ccl;
// only one cache loader may have fetchPersistentState to true.
int numLoadersWithFetchPersistentState = 0;
for (CacheLoaderConfiguration cfg : clmConfig.cacheLoaders()) {
if (cfg instanceof CacheStoreConfiguration) {
CacheStoreConfiguration scfg = (CacheStoreConfiguration) cfg;
assertNotSingletonAndShared(scfg);
if(scfg.fetchPersistentState()) numLoadersWithFetchPersistentState++;
}
if (numLoadersWithFetchPersistentState > 1)
throw new Exception("Invalid cache loader configuration!! Only ONE cache loader may have fetchPersistentState set to true. Cache will not start!");
CacheLoader l = createCacheLoader(LegacyConfigurationAdaptor.adapt(cfg), cache);
ccl.addCacheLoader(l, cfg);
}
} else {
if (!clmConfig.cacheLoaders().isEmpty()) {
CacheLoaderConfiguration cfg = clmConfig.cacheLoaders().get(0);
if (cfg instanceof CacheStoreConfiguration)