Object key = event.getKey();
this.trace("passivated(%s)", key);
StatefulBeanContext bean = event.getValue();
SwitchContext switchContext = switcher.getSwitchContext();
ClassLoader classLoader = this.classLoaderRef.get();
Boolean active = localActivity.get();
localActivity.set(Boolean.TRUE);
try
{
if (!bean.getCanPassivate())
{
// Abort the eviction
throw new RuntimeException(String.format("Cannot passivate bean %s -- it or one if its children is currently in use", key));
}
this.passivatedCount.incrementAndGet();
this.resetTotalSize.set(true);
if (classLoader != null)
{
switchContext.setClassLoader(classLoader);
}
bean.passivateAfterReplication();
}
finally
{
localActivity.set(active);
if (classLoader != null)
{
switchContext.reset();
}
}
}