{
Object result = obj;
// Until we've identified a remote object, we can't assume the orb is
// available in the container. If the orb is not present, this will be null.
ProtocolManager protocolMgr = getProtocolManager();
if (obj instanceof IndirectlySerializable) {
result = ((IndirectlySerializable) obj).getSerializableObjectFactory();
} else if (obj instanceof RemoteBusinessWrapperBase) {
result = getRemoteBusinessObjectFactory
((RemoteBusinessWrapperBase)obj);
} else if ((protocolMgr != null) && protocolMgr.isStub(obj) && protocolMgr.isLocal(obj)) {
org.omg.CORBA.Object target = (org.omg.CORBA.Object) obj;
// If we're here, it's always for the 2.x RemoteHome view.
// There is no remote business wrapper class.
result = getSerializableEJBReference(target, protocolMgr, null);