this.pool = this.ejbContainer.getPool();
ClassLoader cl = this.ejbContainer.getClassloader();
this.classloader = new WeakReference<ClassLoader>(cl);
CacheConfig config = (CacheConfig) ejbContainer.resolveAnnotation(CacheConfig.class);
MBeanServer server = MBeanServerLocator.locateJBoss();
String name = config.name();
if (name == null || name.trim().length() == 0)
name = CacheConfig.DEFAULT_CLUSTERED_OBJECT_NAME;
ObjectName cacheON = new ObjectName(name);
CacheJmxWrapperMBean mbean = (CacheJmxWrapperMBean) MBeanProxyExt.create(CacheJmxWrapperMBean.class, cacheON, server);
cache = mbean.getCache();
cacheNode = new Fqn(new Object[] { this.ejbContainer.getDeploymentPropertyListString() });
// Try to create an eviction region per ejb
region = cache.getRegion(cacheNode, true);
EvictionPolicyConfig epc = getEvictionPolicyConfig((int) config.idleTimeoutSeconds(),
config.maxSize());
region.setEvictionPolicy(epc);
// JBCACHE-1136. There's no reason to have state in an inactive region
cleanBeanRegion();
// Transfer over the state for the region
region.registerContextClassLoader(cl);
try
{
region.activate();
}
catch (RegionNotEmptyException e)
{
// this can happen with nested bean contexts if gravitation
// pulls a parent bean over after the parent region is stopped
// Clean up and try again
cleanBeanRegion();
region.activate();
}
log.debug("initialize(): created region: " +region + " for ejb: " + this.ejbContainer.getEjbName());
removalTimeout = config.removalTimeoutSeconds();
if (removalTimeout > 0)
removalTask = new RemovalTimeoutTask("SFSB Removal Thread - " + this.ejbContainer.getObjectName().getCanonicalName());
}