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

JavaApiDirectoryResource for all of you :-}

From: Alexandre Rafalovitch <alex@access.com.au>
Date: Thu, 15 Aug 1996 19:09:29 +1000
Message-Id: <v02140b00ae388f1464e2@[]>
To: www-jigsaw@w3.org
Hi guys.

Here is my first production that I dared (gasp :-}) to offer you.

How and when do you use it. Most of it is explained in comments in class
body, but here is the gist (sp?). You have a project that has its javadoc
generated api's sitting in a particular directory in Jigsaw servable space
different from directory which has all the standard Java api.. Everything
looks Ok, except for two things. First: images for method name/class names
and all those small balls don't show up. Second: all the standart classes
like String, Object and many others actually generate File Not Found
responce. Isn't that annoying. It is for me.

Ok. Here is the solution. Remove the standard DirectoryResource you had on
you api directory and replace it with JavaApiDirectoryResource. Set
properties of your new JavaApiDirectoryResource so that location points to
directory that keeps standard java api's (that _must be_ under Jigsaw
servable space, you can make a symbolic link on Unix if it is not) and set
index to be packages.html the way you most probably had it before.

Presto. That should have solved all your irritation.

There are couple of other small issues you have to keep in mind.

First, you have to compile the provided file. I have it in
w3c.jigsaw.personal package. If you can't put it there or know a better
place for it, feel free to modify the package AND code of the file where it
refers to the package (2 places, I think).

Second,  you might have to remove .jigidx file from the directory and let
jigsaw reindex it if something goes wrong. For example, I had image
directory and when I got my resource working I tried to remove it and make
my resource redirect image directory requests as well as file requests.
After it, I spent a fare amount of time trying to make Jigsaw reflect the
change. I had to manually go and delete the image directory resource within
api directory resource. It is part of more general issue and I think it
would be solved in next release, but so far just keep it in mind.

Third, my programming style is a bit different from usual java programming
style, but I think it would be easy to get used to. (or at least to
tolerate ti :-})

Also, when I pasted the file, the tabs seem to be a bit off, so you might
have to readjust it if you will edit the file. Sorry about that. I edit on
Unix and send e-mails from Mac :-{.

I welcome any comments on usefulness of this resource and other issues. I
read this list regularly, so any questions would be answered as soon as I
see them (most probably within 2-3 hours of list message reaching
Australia). I can accept praise (if any ;-} ) and other issues people don't
want to put on a list as a personal e-mails too. My e-mail is

Hope you will find the resource useful.

// JavaApiDirectoryResource.java v1.0
// Author: Alexandre Rafalovitch <mailto:alex@access.com.au>
// This file can be used for any purpose and I provide no warranty
// if it will damage your computer or Software.

package w3c.jigsaw.personal;

import w3c.jigsaw.http.*;
import w3c.jigsaw.resources.*;

 * A simple resource that has a single purpose. If a file/directory
 * does not exist within this directory then redirect browser
 * to look up the resource in different predefined directory.
 * <p>
 * This resource was created to deal with a problem of having
 * javadoc documentation of a project in a different directory
 * from the directory of standard api distribution.
 * <p>
 * When location attribute is set to location of standard api
 * directory <strong> within </strong> the servable web space,
 * all the references to standard classes (eg. String and Object)
 * would be transparently redirected to standard distribution where
 * it would be found.
 * <p>
 * This redirection even applies to image directory, even though it
 * probably slows the loading and checking of images down a bit.
 * <p>
 * This resource is not as generic as I would like. It would not work if
 * a resource is not found within an existing child of this resource
 * or deeper. This problem will be solved with next release.
 * @author <A HREF="mailto:alex@access.com.au">Alexandre Rafalovitch </A>
public class JavaApiDirectoryResource extends DirectoryResource
	* Attribute index - URI of resource to lookup if lookup
	* of this resource fails.
	protected static int ATTR_LOCATION = -1;

		Attribute a = null;
		Class     cls = null;
			cls = Class.forName("w3c.jigsaw.personal.JavaApiDirectoryResource");
		} catch(Exception e)

		// Which directory to relocate browser
		// if resource is not found in this directory.
		a = new StringAttribute("location", null,
		ATTR_LOCATION = AttributeRegistery.registerAttribute(cls, a);

	* Get the value of location attribute. Add leading / if needed.
	public String getLocation()
		String location = getString(ATTR_LOCATION, "/");
		return (location.charAt(0) == '/')?location:("/" + location);

	* Lookup the resource and if it is not found, issue redirection.
	public HTTPResource lookup(LookupState state)
		throws HTTPException
		String path = state.getRemainingPath();
		HTTPResource result = null;

			result = super.lookup(state);
			if (result != null)
				return result;
		} catch(HTTPException e)
			if (!e.hasReply() ||
				throw e;

		if (state.isInternal())
			return null;

		// Either null as a result of lookup or HTTP.NOT_FOUND
		// would mean resource is not there.
		Reply reply = state.getRequest().makeReply(HTTP.MOVED_TEMPORARILY);
		String newUrl = getServer().getURL() + getLocation()+ path;
		reply.setContent("Try " + newUrl);
		throw new HTTPException(reply);

Received on Thursday, 15 August 1996 05:09:51 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:29 UTC