Integer maxElementsInMemory = conf.maxElementsInMemory().get();
if( maxElementsInMemory <= 0 )
{
maxElementsInMemory = 10000;
}
CacheConfiguration cacheConfig = new CacheConfiguration( cacheId, maxElementsInMemory );
String transactionalMode = conf.transactionalMode().get();
if( transactionalMode.length() > 0 )
{
cacheConfig.transactionalMode( transactionalMode );
}
Long timeToLiveSeconds = conf.timeToLiveSeconds().get();
if( timeToLiveSeconds > 0 )
{
cacheConfig.timeToLiveSeconds( timeToLiveSeconds );
}
Long timeToIdleSeconds = conf.timeToIdleSeconds().get();
if( timeToIdleSeconds > 0 )
{
cacheConfig.timeToIdleSeconds( timeToIdleSeconds );
}
String name = conf.name().get();
if( name.length() > 0 )
{
cacheConfig.name( name );
}
String memoryStoreEvictionPolicy = conf.memoryStoreEvictionPolicy().get();
if( memoryStoreEvictionPolicy.length() > 0 )
{
cacheConfig.memoryStoreEvictionPolicy( memoryStoreEvictionPolicy );
}
Integer maxElementsOnDisk = conf.maxElementsOnDisk().get();
if( maxElementsOnDisk > 0 )
{
cacheConfig.maxElementsOnDisk( maxElementsOnDisk );
}
Boolean loggingEnabled = conf.loggingEnabled().get();
if( loggingEnabled != null )
{
cacheConfig.logging( loggingEnabled );
}
Boolean eternal = conf.eternal().get();
cacheConfig.eternal( eternal );
Integer diskSpoolBufferSizeMB = conf.diskSpoolBufferSizeMB().get();
if( diskSpoolBufferSizeMB > 0 )
{
cacheConfig.diskSpoolBufferSizeMB( diskSpoolBufferSizeMB );
}
Long diskExpiryThreadIntervalSeconds = conf.diskExpiryThreadIntervalSeconds().get();
if( diskExpiryThreadIntervalSeconds > 0 )
{
cacheConfig.diskExpiryThreadIntervalSeconds( diskExpiryThreadIntervalSeconds );
}
Integer diskAccessStripes = conf.diskAccessStripes().get();
if( diskAccessStripes > 0 )
{
cacheConfig.diskAccessStripes( diskAccessStripes );
}
Boolean clearOnFlush = conf.clearOnFlush().get();
if( clearOnFlush != null )
{
cacheConfig.clearOnFlush( clearOnFlush );
}
// Persistence Configuration
PersistenceConfiguration persistenceConfig = new PersistenceConfiguration();
Strategy strategy = conf.persistenceStrategy().get();
if( strategy == null )
{
persistenceConfig.strategy( Strategy.NONE );
}
else
{
persistenceConfig.strategy( strategy );
}
cacheConfig.persistence( persistenceConfig );
return cacheConfig;
}