The purpose of this class is to fine grain the transfer of some objects over the RMI connection. Implementations of
this class must have a public default constructor, and must have at least one constructor which take a single
argument of the type which is being the subject of transferring.
E.g. If a method is called with a String parameter, it can have a constructor with String,
CharSequence, or other assignable classes as a single parameter. The object to be transferred must be
assignable to at least one of the constructor parameter types.
Serialization:
1. An instance of the RMIWrapper implementation is constructer using an appropriate constructor.
2. The class of the wrapper implementation is serialized over the RMI connection.
3. writeWrapped(
Deserialization:
1. The wrapper class is read from the stream by the RMI runtime.
2. The wrapper is instantiated using the public default constructor.
3. readWrapped(
4. resolveWrapped() is called to retrieve the actual object to pass to the request.
Instances of this interface should only be used to configure the transfer of object and should not be used in the RMI runtime directly. I.e. do not pass instances of RMIWrapper as arguments, return values, etc... for method calls. Any passed objects will be unwrapped using getWrappedObject() regardless of use-case.
If resolveWrapped() returned this
then this method will be called when the wrapper instance
is serialized to an other endpoint. It is preferred to return a remote proxy to the previously wrapped object to
pass back to the original endpoint when reverse request is made. Returning this
from this method
will result in the serialization of this wrapper through RMI.
If resolveWrapped() did not return this
then this method can freely return
null
or throw exceptions (e.g. UnsupportedOperationException) because it will never be
called.
this
.The result of this method will be returned to the caller, or used during the RMI request.
Important aspect of writing objects using wrappers is that in this method if any of the object writing method is called, then the non customizable aspects of the serializable will not be applied to the object that is being wrapped.
E.g. If an RMIWrapper is defined for an object type T, then calling
RMIObjectOutput.writeRemoteObject(