Distributed Objects over HTTP

Juan J. Collas
Moreira Consulting, Inc.


02-Jun-98

Introduction

Apple's Distributed Object infrastructure is an elegant, clean architecture for communicating between objects on different machines.  Its primary limitations are its dependence on the Mach nameserver for transporting messages between systems.  Although this has been fine for small deployments, the protocol does not scale well to the Internet at large, since it requires all systems to run the Mach transport stack, and the overhead for encoding messages is not particularly fast or efficient.

Since the DO classes (NSConnection, NSProxy, NSPort) allow for additional protocols to be implemented under the proxying mechanism, this is an excellent time to consider using the HTTP protocol as a replacement for the existing Mach messaging protocols.  The reasons for this are:

  • Availability.  The Web is built on HTTP servers, and there are many existing services (read: objects) available on the web that can be easily accessed through a HTTP-based DO interface.
  • Inclusiveness.  HTTP is one of the few protocols that is allowed through corporate firewalls.
  • Scalability.  HTTP 1.1 works over long-lived connections.

The DO Architecture

DO consists of two main interfaces: the NSConnection and the NSProxy.  Creating a proxy is done by connecting to a service which returns a local proxy for that service.

    aConn = [NSConnection connectionWithURL:@"http://www.apple.com/cgi-bin/search"];
    aProxy = [aConn rootObject];

    aPage = [aProxy invokeWithArguments:aDict];

Mapping DO to HTTP

The HTTP transport will be implemented as a subclass of NSPort called HTTPPort. This class will also provide a few categories on NSConnection and a class called HTTPProxy.

In DO, the system creates a proxy for each remote object. The NSConnection instance is maintained on a per thread basis and is responsible for maintaining a connection between two tasks, wether on the same or remote machines. The NSConnection instance creates a proxy for each remote object that is refernced.

When using HTTP, things operate a little differently. The primary interface is the proxy itself, which is initialized

    aConn = [NSConnection connectionWithURL:@"http://www.amazon.com/cgi-bin/obidos"];
    aProxy = [aConn rootObject];

should this be something like:

    aProxy = [HTTPProxy proxyWithURL:@"http://www.amazon.com/cgi-bin/obidos"];

 

Messaging Existing ObjC objects

This is done with the dictionary containing:
selector string for selector, 'getArgumentTypeAtIndex:'
args comma separated list of argument values
target the remote object that gets the message

Passing Proxies

These will show up on the remote side as a URL?  Or a proxy back to the object?  Are proxies connections, or referents using a connection to the same host?