if (log_.isTraceEnabled()) {
log_.trace("recv");
log_.trace(getColumnDump(bytes));
}
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new MarshalledValueInputStream(is);
// Read the fqn first
String fqn = ois.readUTF();
ClassLoader oldTcl = null;;
Region region = null;
if(fqn != null && !fqn.equals("NULL"))
{
// obtain a region from RegionManager, if not, will use default.
region = getRegion(fqn);
if(region != null)
{
// If the region has been marked inactive, we still have
// to return a MethodCall or RpcDispatcher will log an Error.
// So, return a call to the TreeCache "_notifyCallOnInactive" method
if (region.getStatus() == Region.STATUS_INACTIVE)
{
if (log_.isTraceEnabled())
{
log_.trace("objectFromByteBuffer(): fqn: " + fqn + " is in the inactive default region");
}
return MethodCallFactory.create(MethodDeclarations.notifyCallOnInactiveMethod,
new Object[] { fqn} );
}
// If the region has an associated CL, read the value using it
ClassLoader cl = region.getClassLoader();
if (cl != null)
{
oldTcl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
if (log_.isTraceEnabled())
{
log_.trace("objectFromByteBuffer(): fqn: " + fqn + " Will use customed class loader " + cl);
}
}
}
else if (defaultInactive_)
{
// No region but default inactive means region is inactive
if (log_.isTraceEnabled())
{
log_.trace("objectFromByteBuffer(): fqn: " + fqn + " is in an inactive region");
}
return MethodCallFactory.create(MethodDeclarations.notifyCallOnInactiveMethod,
new Object[] { fqn} );
}
}
// Read the MethodCall object using specified class loader
Object obj = null;
try
{
obj = ois.readObject();
} finally
{
if (oldTcl != null)
{
Thread.currentThread().setContextClassLoader(oldTcl);