if (id == null) throw new IllegalArgumentException("Can't get an object with a null key");
EnterpriseContext ctx = null;
synchronized (getCacheLock())
{
ctx = (EnterpriseContext)getCache().get(id);
if (ctx != null)
{
return ctx;
}
}
// If the ctx is still null at this point, it means that we must activate it
// => we don't lock the cache during this operation
// StatefulSessionInstanceInterceptor prevents multiple accesses for the same id
//
try
{
ctx = acquireContext();
setKey(id, ctx);
activate(ctx);
logActivation(id);
insert(ctx);
}
catch (Exception x)
{
if (ctx != null)
freeContext(ctx);
log.debug("Activation failure, id="+id, x);
throw new NoSuchObjectException(x.getMessage());
}
// FIXME marcf: How can this ever be reached? the ctx is always assigned
if (ctx == null) throw new NoSuchObjectException("Can't find bean with id = " + id);
return ctx;