Indexer configuration
In this section, the Jigsaw2.0 version of the indexing scheme will be presented.
The Jigsaw1.0 scheme is easy to find out as it is much simpler than the 2.0
one (no protocol frames).
Goal of an indexer
The main goal of an indexer is to create and setup some resource automatically.
The resources can be created depending on their name or their extension.
Once the resource has been created, the indexer is also in charge of attaching
the right frames to this resource, like the HTTP frame, the filters and so
on.
Description of an indexer
-
Class and attributes of an indexer
-
Class:
-
Usually, the indexer's class is
org.w3c.tools.resources.indexer.SampleResourceIndexer
-
identifier
-
The name of the indexer, ex: "icons"
-
Last-modified
-
Unused, but resent as, internally, it is a resource.
-
super-indexer
-
The name of the parent indexer used when the current indexer fails to index.
By default, the super indexer is the "default" indexer.
-
The sons of an indexer
-
directories
-
Used to index files matching exactly a name, mainly used to index directories.
You can specify that an "Icons" directory will always be negotiable, for
example. The default name (ie: matching all directory names) is "*default*"
-
extensions
-
Used to index files with a specific extension. For example, "html" is a
FileResource with an HTTPFrame set to give the "text/html" content type to
this file. Then all the "foo.html" files will be indexed as "text/html" type
object when accessed by HTTP. The default extension (ie: matching all the
extension names) is "*default*". To index files with no extensions, you must
use the name "*noextension*".
Setting up the indexer
We will use a small example. The indexer will create all directories named
"Icons" as a normal DirectoryResource, but using "icons" as its indexers.
It means that all the Icons directories and their subdirectories will be
indexed with "icons" instead of "default". Along with that, we will define
a new extension "mpg" as a "video/mpeg" object.
-
Open a jigadmin window
-
Go to the server you want to add the indexer to (usually http-server), click
on the "indexer" node. On the right side, you must see the indexer helper,
like this.
-
Create an indexer. To do so, put a name in the identifier textfield (ex:
"testindexer"), then, using the pulldown menu, select the class of indexer
you want to use. The common indexer is
org.w3c.tools.resources.indexer.SampleResourceIndexer
click
on the "Add Indexer" button and you are all set for the next step:
-
You now have a "testindexer" node. Open this node and you will see the two
directories "directories" and "extensions", as described above. The Attribute
helper shows the super-indexer field. Let it blank as there is no specific
indexer to call before asking the default indexer if this one fails.
-
Click on "directories", the resource helper appears on the right part of
the window, type "Icons" in the indentifier textfield, and select
org.w3c.tools.resources.DirectoryResource
using the pull-down
menu. It means that all the directories named "Icons" will be created as
a DirectoryResource. You have now to configure this resource.
-
Click on the new "Icons" directory under the "directories" node, the resource
helper appears first. We want to change the indexer on this resource, so
click on the Attribute button to show the right helper. You have now the
attributes, amongst them, the indexer. Select "icons" using the option menu,
then click on "Commit" to confirm your changes. BEWARE! The indexer is not
yet completely setup, as this resource can't be accessed in any way! You
need to add a ProtocolFrame to allow one protocol to access this resource.
To do so, Click on the "Frames" button to invoke the frame helper. Select
the most basic protocol frame:
org.w3c.jigsaw.frames.HTTPFrame
and
add it to the resource. Click now in the small tree browser below,
HTTPFrame (frame-0)
should appear. Click on it and you will
be able to configure the HTTPFrame (which looks like an old Jigsaw-1.0 Resource)
set the icon to dir.gif to enhance it.
-
Now you have to create the new extension. You must use the same process as
above, except for some details. Add the "mpg" resource with the
org.w3c.tools.resources.FileResource
class to the "extensions"
directory. Then add an HTTPFrame to it, open the "mpg" node in the little
tree browser. Change the mime type, by selecting the right one (video/mpeg)
in the content-type editor. Add movie.gif as the default icon for directory
listing, commit.
-
You are all set now, don't forget to save your changes using the control
resource of the server. You can now use this indexer.
Of course this is an example, if you want to add an extension for the whole
server, the best way is to add it directly in the default indexer. Another
thing, it is better to use org.w3c.jigsaw.resources.DirectoryResource
than org.w3c.tools.resources.DirectoryResource
, just
to check if you read ALL the documentation ;)
Jigsaw Team
$Id: indexers.html,v 1.18 1998/03/02 15:28:54 yves Exp $