private Object writeReplace() throws ObjectStreamException { CMIReference ref = getReference(); if(ref.getServerRef().getProtocol().equals("iiop")) { String ior; try { ior = Utility.remote_to_string(getReferencedObject()); } catch (NamingException e) { throw new InvalidObjectException("Cannot get the ior from the stub " + getReferencedObject()); } return new RemoteCMIReferenceableWrapper<T>(ref, ior); } else { return this; } }
@SuppressWarnings("unchecked") private Object readResolve() throws ObjectStreamException { CMIReference ref = getReference(); if(ref.getServerRef().getProtocol().equals("iiop")) { T remote; try { remote = (T) Utility.string_to_remote(ior); } catch (NamingException e) { throw new InvalidObjectException("Cannot get the stub from the ior " + ior); } return new RemoteCMIReferenceableWrapper<T>(ref, remote); } else { return this; } }