Class ZippedProxy

java.lang.Object
gnu.cajo.utils.ZippedProxy
All Implemented Interfaces:
Invoke, Serializable, Remote
Direct Known Subclasses:
HashedProxy

public class ZippedProxy extends Object implements Invoke
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

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Constructor
    Description
    The constructor retains the reference to the proxy, until the server reference is provided by the ItemServer, after that, it is serialized into the payload array, and discarded.
  • Method Summary

    Modifier and Type
    Method
    Description
    final Object
    invoke(String method, Object args)
    The interface to the proxy wrapper.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • payload

      protected byte[] payload
      The 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

      protected transient Object 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

      public ZippedProxy(Object proxy)
      The constructor retains the reference to the proxy, until the server reference is provided by the ItemServer, 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

      public final Object invoke(String method, Object args) throws Exception
      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 interface Invoke
      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.