readObject
for custom serialization.
This method reads this object's serialized form for this
class as follows:
The readObject
method is invoked on
in
to read this object's unique identifier
(a {@link java.rmi.server.UID UID} instance).
Next, the readUTF
method is invoked on
in
to read the external ref type name of the
RemoteRef
instance for this object's
activator. Next, the RemoteRef
instance is created of an implementation-specific class
corresponding to the external ref type name (returned by
readUTF
), and the readExternal
method is invoked on that RemoteRef
instance
to read the external form corresponding to the external
ref type name.
Note: If the external ref type name is
"UnicastRef"
, "UnicastServerRef"
,
"UnicastRef2"
, "UnicastServerRef2"
,
or "ActivatableRef"
, a corresponding
implementation-specific class must be found, and its
readExternal
method must read the serial data
for that external ref type name as specified to be written
in the serialData documentation for this class.
If the external ref type name is any other string (of non-zero
length), a ClassNotFoundException
will be thrown,
unless the implementation provides an implementation-specific
class corresponding to that external ref type name, in which
case the RemoteRef
will be an instance of
that implementation-specific class.
uid = (UID)in.readObject();
try {
Class<? extends RemoteRef> refClass =
Class.forName(RemoteRef.packagePrefix + "." + in.readUTF())
.asSubclass(RemoteRef.class);
RemoteRef ref = refClass.newInstance();
ref.readExternal(in);
activator = (Activator)
Proxy.newProxyInstance(null,
new Class<?>[] { Activator.class },
new RemoteObjectInvocationHandler(ref));
} catch (InstantiationException e) {
throw (IOException)
new InvalidObjectException(
"Unable to create remote reference").initCause(e);
} catch (IllegalAccessException e) {
throw (IOException)
new InvalidObjectException(
"Unable to create remote reference").initCause(e);
}