W3C home > Mailing lists > Public > www-jigsaw@w3.org > July to August 1996

new filter model [fwd message]

From: Anselm Baird-Smith <abaird@w3.org>
Date: Fri, 26 Jul 1996 08:33:14 +0500
Message-Id: <9607261233.AA23665@www18.w3.org>
To: www-jigsaw@w3.org
Alexandre Rafalovitch writes:
 > Hi,
 > 
 > For a fun and for use of public, I am trying to write a filter that would
 > log a referer of non-existing files.
 > Everything was fine, but when I wrote the file and tested it, I found out
 > that it only works if an _indexed_ file does not exist. That is, if a file
 > is indexed by Jigsaw but then is removed from the filesystem.
 > 
 > This is already useful, but I was hoping actually to be able to log also
 > non-existing files. Unfortunately, I cannot do that because filters are not
 > called when file does not exist at all. So, if somebody misspelled a link
 > to my file from his/her page, I will never know.

Correct ! There is a severe design bug with regard to filter, which
has been cleaned up (and which will be included in the next
release). Basically your explanations are correct: filters get called
*only* if a target resource is found. We discovered this while trying
to implementn an ErrorFilter that allow for error msg custmoiization
(it has to catch all errors, and do an internal request to get the
actual error message to emit). 

The new filter model (which includes a minor change to the filter API)
is now much cleaner, although a little more complex. Here is the basic
idea:

The lookup method of a resource now returns two things: a target
resource (or null if not found), and a set of filters to be applied
when accessing the resource. The perform method of HTTPResource now
takes as an aditional argument, the filters to be run before performing
the request. The httpd class has a new method which does all this for
you, here is a sketch of how it goes:

class httpd {
    Reply perform (Request request) {
        LookupState ls = new LookupState(request) ; // prepare lookup state
        LookupResult lr = new LookupResult();
        // lookup:
        getRoot().lookup(ls, lr);
        // Check for an existing target:
        if (lr.hasTarget())
            return lr.getTarget().perform(request, lr.getFilters());
        // No target found, we still want to run the filters:
        Reply reply = request.makeReply(HTTP.NOT_FOUND);
        HTTPFilter filters[] = lr.getFilters();
        for (int i = 0 ; i < filters.length ; i++)
            filters[i].outgoingFilter(request, reply);
    }
...
}

This ensures that filters will always be called, even in case the
resource wasn't found, so the next release of Jigsaw will include an
ErrorFilter that works :-)

Also, the new filter model provides support to write the following new
filters (which might - if time allows - be included in next release
too):

a) A CachingFilter. This filter will maintain a memory-based cache of
all the documents it applies to. It is likely that - applied to your
server icons directory - this will provide a tremendous speedup.
b) A LookupCache filter, to shortcut the lookup phase: plug it on the
root resource, it will keep a cache of lookup results (so that lookup
is no more proportional to the depth of the URL).

These two filters, along with the ErrorFilter were the one that lead
us to redesign the filtering model, all of them are now (hopefully)
implementable. If you think of the above two filters, you will
understand the complex kind of costraints they put on the filtering
model: 

For a) a filter should be able to emit a reply on behalf of a
resource, but still after running all the filters that aplpies to the
resource.
For b) lookup can be shortcut by a filter

Beleive me, we (Antonio Ramirez helped a lot, you will soon hear more of
him) had a hard time redesigning the filter model.

 > Is that the way filter model going to stay, or there are any major changes
 > to the way it works. Maybe, I can release what I have done now and enhance
 > it later when (if) it is possible.

The above change will solve all your problems.

 > Any ideas, or people think finding misconfigured links is good enough and I
 > should release the code to the public?

Alex, I would be really interested in including your code in Jigsaw
next release. I'll followup through private email.

Anselm.
Received on Friday, 26 July 1996 08:33:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:25 GMT