Class ZippedProxy

  • All Implemented Interfaces:
    Invoke, java.io.Serializable, java.rmi.Remote
    Direct Known Subclasses:
    HashedProxy

    public class ZippedProxy
    extends java.lang.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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] payload
      The compressed serialized proxy object.
      protected java.lang.Object proxy
      A reference to the internal proxy object, before serialization at the server, and when decompressed on arrival at the host.
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      ZippedProxy​(java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object invoke​(java.lang.String method, java.lang.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 Detail

      • 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 java.lang.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 Detail

      • ZippedProxy

        public ZippedProxy​(java.lang.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 Detail

      • invoke

        public final java.lang.Object invoke​(java.lang.String method,
                                             java.lang.Object args)
                                      throws java.lang.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:
        java.lang.Exception - For any proxy-specific reasons.
        java.rmi.RemoteException - For any network related errors.