W3C logoJigsaw

Jigsaw 2.0 Internal design

The new Resource

In the previous version of Jigsaw (1.0), the inheritance tree of Resources was:

All the basic Resources, such as FileResource and DirectoryResource, were heavily linked to HTTP as all the resources served were extensions protocols that are not HTTP-related, we propose this new version of the Resource:

Where (1) and (2) are ResourceFrames. A Resource is now a very basic thing, containing only information that the raw Resource can provide (e.g., for a file, the size, last modification date, creation date if available, etc.), then, attached to that Resource, we find the ResourceFrames that extend Resource (they are handled the same way) and contain information about the Resource they are attached to.

To serve a resource using a protocol -- for instance, HTTP -- the Resource will have a protocol ResourceFrame, HTTPFrame, that contains all the information needed to serve this Resource using HTTP. This frame is like the old version of HTTPResource, but it contains more information than the previous version.

The filters are now divided in two categories: the filters on the Resource and the filters on the protocol Frames. The usual filtering scheme used in the previous version of Jigsaw is still valid. The main difference is that filter sare no longer attached to the Resource itself but to its protocol frame. ResourceFrames can also have frames.

Other kind of frames can be attached, like RDF frame for metadata, PICS frame to rate this resource, etc...

The new inheritance tree is:

more complex, but more flexible than the previous version.

The new ResourceStoreManager

In order to share all the Resources amongst different servers efficiently, we created a new central ResourceStoreManager. In the previous version the Resources were handled by other Resources. For example, the FileResource was handled by its DirectoryResource. This induced a number of bugs and was not very well-adapted to the new way of sharing Resources. There is now only one manager for the server handler so that each server will talk to this sole manager.

This RSM contains a hashtable associating a key (unique indentifier of a ResourceContainer) and a StoreEntry. The StoreEntry contains the store of the resource sons and a hashtable associating the identifier of the sons of the resource and the ResourceReference of those resources.

The ResourceReference is used like this:

  ResourceReference rr;
  ....
  try {
     Resource res = rr.lock();
     ....
  } catch (InvalidResourceException ex) {
    /* InvalidResource means that the resource has been deleted */
     ....
  } finally {
    rr.unlock();
  }
  ...

If the resource has been garbage-collected, the rr.lock() will load it again, and during the lock, it is guaranteed that the resource won't be deleted, unloaded or modified by someone else. This allows safe concurrent modification access to this resource.

Now the container is no longer responsible for the management of its son; it only has a key to the StoreEntry, which contains its sons. To get its own store, the resource has to ask its parent for the StoreEntry that contains it.

The lookup and perform algorithm

This part describe the lookup and the perform algorithm used by Jigsaw.

The following picture show a Jigsaw resources tree (relative to the URL /archives/index.html), where root and archives are DirectoryResource (root is the root resource) and index.html is a FileResource. F1, F2 and F3 are filters (ResourceFilter subclass instance).

In the following description, Jigsaw receive an HTTP GET request for /archives/index.html. To handle the incomming request, Jigsaw will go through the following steps:

  1. Lookup for /archives/index.html
  2. Call the ingoingFilter method of filters
  3. Perform the request
  4. Call the outgoingFilter method of filters
  5. Emit the reply

1) Lookup for /archives/index.html. The LookupState (ls) keeps the state info, and the LookupResult (lr) is the result of the lookup algorithm.

root lookup(ls,lr)
    -> HTTPFrame1 lookup(ls,lr)
        -> F1 lookup(ls,lr)
        -> HTTPFrame1 lookupDirectory(ls,lr)
    -> archives lookup(ls,lr)
        -> HTTPFrame2 lookup(ls,lr)
            -> F2 lookup(ls,lr)
            -> HTTPFrame2 lookupDirectory(ls,lr)
        -> index.html lookup(ls,lr)
            -> HTTPFrame3 lookup(ls,lr)
                -> F3 lookup(ls,lr)
                -> HTTPFrame3 lookupFile(ls,lr) => index.html

2) Call the ingoingFilter method of filters. Request is the incomming request.

F1 ingoingFilter(Request)
F2 ingoingFilter(Request)
F3 ingoingFilter(Request)

Note that if any filter answer with a non-null Reply, the process is stopped and the Reply is sent back to the client directly (like in the GenericAuthFilter)

3) Perform the request (GET) on the resource found at lookup time.

index.html perform(Request)
    -> HTTPFrame3 perform(Request)
        -> HTTPFrame3 get(Request)
            -> HTTPFrame3 getFileResource(Request) => Reply

4) Call the outgoingFilter method of filters. Request is the incomming request, Reply is the reply created by HTTPFrame3.

F3 outgoingFilter(Request, Reply)
F2 outgoingFilter(Request, Reply)
F1 outgoingFilter(Request, Reply)

 5) Emit the reply created by HTTPFrame3.


Jigsaw Team

$Id: design.html,v 1.26 1998/10/01 09:15:08 ylafon Exp $

Copyright © 1997 W3C (MIT, INRIA, Keio ), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply. Your interactions with this site are in accordance with our public and Member privacy statements.