Request Encoding as Objects Proxies

Proxies are the fundamental backbone of Request Encoding as Objects. In a nutshell, each Request Encoding as Objects implementation is language specific and is used to generate a proxy class allowing the language to communicate with other Request Encoding as Objects implementations. Every class that is "exported" to another Request Encoding as Objects process must have a proxy class defined for it in the client process prior to being able to receive the object id.

At the bare minimum, every proxy must follow a specific set of Request Encoding as Objects rules:

Namespaces

All proxy classes must occur in the same namespace as the class for which it is proxying. eg, the class "org.casbah.cairo.CairoAdaptor" in Java is in the namespace "org.casbah.cairo". The proxy for this class must also occur in the "org.casbah.cairo" namespace. [1]

Proxy Name

Every proxy class must be named the same name as the class for which it is proxying. eg, the class "org.casbah.cairo.CairoAdaptor" in Java is named "CairoAdaptor". The proxy must also be named "CairoAdaptor".

Proxy Instance Data

Every proxy instance must know four pieces of information:

Table 1. Required Data

Item

Rationale

ObjectID

Identifies this object to the server, needed in order to properly form a method call on the Lightweight Distributed Objects (LDO) stream.

ServerID

Needed to inform other clients about the server that this object is located at. Mainly used to supply them with the ServerID to prevent an A-B-C call chain.

ServerAddress

Needed to inform other clients about where this object lives. Also used to try and prevent an A-B-C call chain.

Request Encoding as ObjectsConnection

Allows access to the actual Lightweight Distributed Objects (LDO) stream to send and receive data to/from the object's server.

For most implementations, the ObjectID and a pointer to the Request Encoding as Objects connection object (which should already contain the ServerID and ServerAddress) will be sufficient.

Pointer Equality

Pointer equality on the object's server must also be represented on the client side of the Request Encoding as Objects connection. eg, the following Java method must print out the string "Correct" on all Request Encoding as Objects implementations:

/*
 * Server
 *
 * Class SomeServer is actually implemented here.
 * it has already been set by another (not shown)
 *    method.
 */
class SomeServer
{
    Object    it;

    Object getIt()
    {
        return it;
    }
}
                /*
 * Client
 *
 * SomeServer is a proxy to the above class.
 * serv is an instance of this proxy referring
 *    to an already constructed instance of 
 *    SomeServer on the remote &reo; process.
 */
void test_reo(SomeServer serv)
{
    Object a;
    Object b;

    a = serv.getIt();
    b = serv.getIt();
    if (a == b)
    {
      system.out.println("Correct");
    } else
    {
      system.out.println("This LDO Layer II implementation is broken"
        + " as pointer equality does not function correctly."
+ "  Please re-read the Layer II documentation.");
    }
}

This example assumes that the field it of the instance referred to by the proxy in argument serv has not been modified between the two calls to method getIt.

Pointer equality is important on the client side of all Request Encoding as Objects connections, as it allows fast comparision of all proxy objects. It also ensures that the client side knows how many references to an object exist inside of the process, allowing systems which support weak references or DESTROY methods to inform the server of proxy invalidation.

Implementations should maintain a hashtable of all object ID's, storing the proxy instance pointer as the value for the key. This allows fast translation from ObjectID to proxy instance. On some langauge systems, the hashtable translation may be faster than constructing a new proxy.[2]

Proxy methods may contain any code that is necessary for the Request Encoding as Objects implementation to operate correctly. Note that proxies may not be interchangeable between Request Encoding as Objects implementations, even if they are for the same programming language/ environment. Each Request Encoding as Objects implementation must assume that it cannot use proxies from another Request Encoding as Objects implementation. In order to help implementations prevent proxy conflicts, all Request Encoding as Objects applications must not use more than one Request Encoding as Objects implementation.

No Request Encoding as Objects implementation should check to see if the proxy class it is using is its own or another implementation's proxy class. This should be an issue dealt with by the user, and therefore the associated cost of verifying proxy class correctness is not necessary.

Notes

[1]

The authors of this document understand that namespaces and packages are not always the same thing. For the purposes of Request Encoding as Objects packages in Java will be used as Request Encoding as Objects namespaces.

[2]

For at least Python and Perl this is true. It may be true for other languages, such as Java, depending on the cost of allocating the memory to hold the new proxy instance.