Package gnu.cajo.utils
Class ZippedProxy
java.lang.Object
gnu.cajo.utils.ZippedProxy
- All Implemented Interfaces:
Invoke
,Serializable
,Remote
- Direct Known Subclasses:
HashedProxy
This class is used to transfer its internal proxy object as a zipped
marshalled object (zedmob). It will decompress the proxy automatically on
arrival at the client. This will incur a small runtime penalty, however, if
the proxy is large and highly compressable, or the data link is slow, or the
cost per byte to transmit data is high, this can become highly advantageous.
The proxy is serialized and compressed once the server reference is
provided to it by the
ItemServer
during the binding of
its server object. After that it can no longer be modified at the server.
If the server loads proxies into its runtime, i.e. it is not using a
ProxyLoader
, it is highly recommended to use
zipped proxies, since processor horsepower is increaseing steadily, while
long-haul network bandwidth is not.
The class is not final; this allows subclasses to have no-arg constructors, using a proxy of their choosing. Also, a subclass could optionally encrypt the payload before sending, and decrypt it on arrival, if necessary.
- Version:
- 1.0, 01-Nov-99 Initial release
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
The compressed serialized proxy object.protected Object
A reference to the internal proxy object, before serialization at the server, and when decompressed on arrival at the host.private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionZippedProxy
(Object proxy) The constructor retains the reference to the proxy, until the server reference is provided by theItemServer
, after that, it is serialized into the payload array, and discarded. -
Method Summary
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
payload
protected byte[] payloadThe compressed serialized proxy object. It is created on server assignment when binding at the hosting VM. This is to save time and memory, especially if the same proxy is sent many times, at the expense of no longer being able to modify the proxy. It is nulled at the client, following proxy decompression, to allow the unneeded memory to be garbage collected. -
proxy
A reference to the internal proxy object, before serialization at the server, and when decompressed on arrival at the host. It is nulled after serialization at the server, to allow its unused memory to be garbage collected, since the paylod image can no longer be updated.
-
-
Constructor Details
-
ZippedProxy
The constructor retains the reference to the proxy, until the server reference is provided by theItemServer
, after that, it is serialized into the payload array, and discarded. If there are no other references to the proxy, it will be garbage collected.- Parameters:
proxy
- The internal proxy object.
-
-
Method Details
-
invoke
The interface to the proxy wrapper. It is only to be called once by the sending VM, to store a remote reference to itself. Following that, it is only invoked by the receiving VM. Following its arrival at the host VM, the proxy will be decompressed at its first invocation.- Specified by:
invoke
in interfaceInvoke
- Parameters:
method
- The public method to invoke on the internal proxy object, following the initial invocation, which is used to compress the proxy.args
- First the remote server reference, following that, callback data from any outside VMs to be given to the internal proxy.- Returns:
- Any synchronous data defined by a subclass' implementation, it can be an array of of objects, or possibly null
- Throws:
Exception
- For any proxy-specific reasons.RemoteException
- For any network related errors.
-