File configFile = tomcatConfig.getCacheConfigFile();
String clusterName = tomcatConfig.getClusterName();
if (configFile != null)
{
pcWrapper = new PojoCacheJmxWrapper(PojoCacheFactory.createCache(configFile.getAbsolutePath(), false));
Configuration config = pojoCache.getCache().getConfiguration();
if (clusterName != null)
{
// Override the XML config with the name provided in
// server.xml. Method setClusterName is specified in the
// Cluster interface, otherwise we would not do this
config.setClusterName(clusterName);
}
}
else
{
// User did not try to configure the cache.
// Configure it using defaults. Only exception
// is the clusterName, which user can specify in server.xml.
Configuration config = new Configuration();
String channelName = (clusterName == null) ? DEFAULT_CLUSTER_NAME
: clusterName;
config.setClusterName(channelName);
config.setIsolationLevel(DEFAULT_ISOLATION_LEVEL);
config.setCacheMode(DEFAULT_CACHE_MODE);
config.setLockAcquisitionTimeout(DEFAULT_LOCK_TIMEOUT);
config.setTransactionManagerLookupClass(DEFAULT_TM_LOOKUP);
pcWrapper = new PojoCacheJmxWrapper(PojoCacheFactory.createCache(config, false));
}
if (server != null && objName != null)
{
server.registerMBean(pcWrapper, objName);