Methods Summary |
---|
public Cache | buildCache(java.lang.String regionName, java.util.Properties properties)Construct and configure the Cache representation of a named cache region.
return new OptimisticTreeCache( cache, regionName );
|
public org.jboss.cache.TreeCache | getUnderlyingCache()
return cache;
|
public boolean | isMinimalPutsEnabledByDefault()
return true;
|
public long | nextTimestamp()
return System.currentTimeMillis() / 100;
|
public void | start(java.util.Properties properties)Prepare the underlying JBossCache TreeCache instance.
String resource = properties.getProperty( Environment.CACHE_PROVIDER_CONFIG );
if (resource == null) {
resource = properties.getProperty( CONFIG_RESOURCE );
}
if ( resource == null ) {
resource = DEFAULT_CONFIG;
}
log.debug( "Configuring TreeCache from resource [" + resource + "]" );
try {
cache = new org.jboss.cache.TreeCache();
PropertyConfigurator config = new PropertyConfigurator();
config.configure( cache, resource );
TransactionManagerLookup transactionManagerLookup =
TransactionManagerLookupFactory.getTransactionManagerLookup( properties );
if ( transactionManagerLookup == null ) {
throw new CacheException(
"JBossCache only supports optimisitc locking with a configured " +
"TransactionManagerLookup (" + Environment.TRANSACTION_MANAGER_STRATEGY + ")"
);
}
cache.setTransactionManagerLookup(
new TransactionManagerLookupAdaptor(
transactionManagerLookup,
properties
)
);
if ( ! NODE_LOCKING_SCHEME.equalsIgnoreCase( cache.getNodeLockingScheme() ) ) {
log.info( "Overriding node-locking-scheme to : " + NODE_LOCKING_SCHEME );
cache.setNodeLockingScheme( NODE_LOCKING_SCHEME );
}
cache.start();
}
catch ( Exception e ) {
throw new CacheException( e );
}
|
public void | stop()
if ( cache != null ) {
cache.stop();
cache.destroy();
cache = null;
}
|