Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / jigsaw / WWW / User / Introduction / indexer.html
diff --git a/JMCR-Stable/real-world application/jigsaw/WWW/User/Introduction/indexer.html b/JMCR-Stable/real-world application/jigsaw/WWW/User/Introduction/indexer.html
new file mode 100644 (file)
index 0000000..d7fe4e4
--- /dev/null
@@ -0,0 +1,206 @@
+<HTML>\r
+<HEAD>\r
+  <!-- Changed by: Anselm Baird-Smith,  4-Feb-1997 -->\r
+  <TITLE>Jigsaw Indexer</TITLE>\r
+</HEAD>\r
+<BODY BGCOLOR="white">\r
+<P>\r
+<A HREF="http://www.w3.org/pub/WWW/" TARGET="_top_"><IMG BORDER="0" ALT="W3C" SRC="/icons/WWW/w3c_home.gif"\r
+    WIDTH="72" HEIGHT="48"></A>\r
+<A HREF="http://www.w3.org/pub/WWW/Jigsaw/" TARGET="_top_"><IMG SRC="/icons/jigsaw" WIDTH="212"\r
+    HEIGHT="49" ALT="Jigsaw" BORDER="0"></A>\r
+<H1>\r
+  Jigsaw Resource Factory\r
+</H1>\r
+<P>\r
+The <B>Jigsaw</B> resource factory is a modular piece of software that runs\r
+behind the scene, and creates\r
+<CODE><A HREF="../Reference/w3c.jigsaw.resources.HTTPResource.html">HTTPResource</A></CODE>\r
+instances out of existing data. The factory currently knows about files and\r
+directories of the underlying file system, but you can extend it to handle\r
+more objects, at will.\r
+<P>\r
+This document describes <I><A HREF="#when">when</A></I> the factory is called\r
+and <I><A HREF="#how">how</A></I> it maps any existing data source to HTTP\r
+exportable <I>resources</I>.\r
+<H2>\r
+  <A NAME="when">When is the factory invoked</A>\r
+</H2>\r
+<P>\r
+Each running server has a resource factory attached to it (which it might\r
+share with other server, but this is not relevant here). Any resource can\r
+call its server factory in order to create a resource out of an existing\r
+object. Currently, the only resource that does so is the\r
+w3c.jigsaw.resources.StoreContainer, which is the base class for most resource\r
+containers (such as the one exporting directories).\r
+<P>\r
+When queried for an URL component, at lookup time, the directory resource\r
+first checks its children resource store for a matching resource, if such\r
+a resource is found, than it is returned as the target of the lookup, otherwise,\r
+if the directory is flaged as extensible, the directory resource derives\r
+a file name from the resource's identifier, and goes to the resource factory\r
+to obtain a wrapping resource instance. If such a resource is built successfully\r
+by the factory, the directory resource installs it as one of its children\r
+resources, and manages its persistency.\r
+<P>\r
+Let's walk through this algorithm with an example. Suppose there is a directory\r
+resource <CODE>User</CODE> which wraps an underlying file-system directory\r
+named <CODE>User</CODE>. This directory resource will usually be created\r
+empty (with no children resources). At some point, a client will ask for,\r
+say, <CODE>User/Overview.html</CODE>. The lookup process starts, and after\r
+some iterations comes to the point were it looks for\r
+<CODE>Overview.html</CODE> in the directory resource <CODE>User</CODE>. The\r
+directory resource looks into its children resources to find it, as none\r
+is found, it goes to the resource factory, and asks it to construct a resource\r
+for the file <CODE>Overview.html</CODE>. If a resource is returned (which\r
+depends on the <A HREF="#configuration">factory configuration</A>), the directory\r
+resource plugs the newly created resource into its resource store, and returns\r
+it as the target of the lookup.\r
+<P>\r
+One important note here: as resources are persistent objects (they persist\r
+across <B>Jigsaw</B> invocations), resources that wrap existing objects are\r
+created only <I>once</I> in the whole lifetime of the server. This means\r
+that changing the factory configuration <I>after</I> a resource has been\r
+indexed, has no effect on the resources that have already been created. This\r
+is one of the features that makes the server fast: indexing an existing object\r
+into a resource might be a costly process (it will involve querying multiple\r
+databases, such as the extensions and directory templates database, etc.).\r
+Caching the result of this operation allows the server to concentrate on\r
+its real work, which is to serve data back to clients. You may still however,\r
+want to change the resource factory configuration, and re-index part of your\r
+information space with these new options. Currently the only way to do that\r
+is to delete the resources to be re-indexed and have them recreated through\r
+the normal mechanism.\r
+<H2>\r
+  <A NAME="how">How the factory creates resources</A>\r
+</H2>\r
+<P>\r
+The factory is defined in terms of a set of <I>indexers</I>. Each container\r
+resource may specify the indexer to use to index its content, through its\r
+<B>indexer</B> attribute which should provide the valid name of a registered\r
+indexer. You could implement for example, a <I>MailMessageIndexer</I> that\r
+would create resources out of a berkley-like mail box file, and have a\r
+<I>MailResource</I> use it to export it.\r
+<P>\r
+The default indexer class, in current Jigsaw release is the\r
+<I>w3c.jigsaw.indexer.SampleresourceIndexer</I>, which knows only about files\r
+and directories. It creates resources by maintaing two databases: the\r
+<I>extension</I> database is used to index files, while the\r
+<I>directories</I> database is used for directories indexing.\r
+<H3>\r
+  The extension database\r
+</H3>\r
+<P>\r
+When the sample resource indexer is called to index a normal file, the first\r
+thing it does is to split the file name into its raw name, plus its set of\r
+extensions. So, for example, if the file to be indexed if\r
+<CODE>foo.en.html.gz</CODE>, the raw name will be <CODE>foo</CODE>, and the\r
+set of extensions will be {<CODE>en</CODE>, <CODE>html</CODE>,\r
+<CODE>gz</CODE>}.\r
+<P>\r
+It then take each extension description record, and look if it defines a\r
+resource class. In a typicall setting, only the <CODE>html</CODE> extension\r
+will have an associated resource class, which is likely to be the\r
+<CODE><A HREF="../Reference/w3c.jigsaw.resources.FileResource.html">FileResource</A></CODE>\r
+class. This gives the indexer the class of the resource to build for the\r
+given file, so the indexer carries on by creating an empty instance of this\r
+class. It then creates a set of default attribute values, first by defining\r
+the following pre-defined set of attributes:\r
+<UL>\r
+  <LI>\r
+    The resource <CODE>identifier</CODE> defaults to the file name,\r
+  <LI>\r
+    The resource physical <CODE>directory</CODE> defaults to the file directory,\r
+  <LI>\r
+    The <CODE>last-modified </CODE>time defaults to the last-modified time of\r
+    the file\r
+  <LI>\r
+    The c<CODE>ontent-length</CODE> defaults to the length of the file.\r
+</UL>\r
+<P>\r
+Then for each of the file extensions, it looks into the associated database\r
+record, and fill in the remaining attributes. The <CODE>html</CODE> extension\r
+record, for example, might define the default value for\r
+<CODE>content-type</CODE> to <B>text/html</B>. The <CODE>en</CODE> extension\r
+record will probably define the <CODE>content-language</CODE> default value\r
+to <B>en</B>, and finally the <CODE>gz</CODE> extension record will probably\r
+state that the resource's <CODE>content-encoding</CODE> default value should\r
+be <B>x-gzip</B>. Once the set of default attribute values is constructed,\r
+the resource is initialized, and returned.\r
+<H3>\r
+  The directory templates database\r
+</H3>\r
+<P>\r
+When the factory is called to index a directory, it examines its <I>directory\r
+templates</I> database. This database allows the web admin to map directory\r
+names to specific sub-classes of resources. \r
+<P>\r
+For each directory template, the web admin first specifies an appropriate\r
+resource class. A typicall setting, might specify, for example, that all\r
+directory named <CODE>Putable</CODE> should be exported by an instance of\r
+the <CODE>PutableDirectory</CODE>. \r
+<P>\r
+The class attached to a directory template needs not be a sub-class of the\r
+<CODE><A HREF="../Reference/w3c.jigsaw.resources.DirectoryResource.html">DirectoryResource</A></CODE>.\r
+You can specify, for example, that directories named <CODE>CVS</CODE> should\r
+be exported through a\r
+<CODE><A HREF="../Reference/w3c.jigsaw.cvs.CvsDirectoryResource.html">CvsDirectoryResource</A></CODE>,\r
+which will provide you with a form-based interface to CVS.\r
+<H2>\r
+  <A NAME="configuring">Configuring the factory</A>\r
+</H2>\r
+<P>\r
+Configuring <B>Jigsaw</B> factory consists of editing the set of indexers,\r
+and for each indexer editing the <I>extensions</I> and <I>directory\r
+templates</I>databases. This can be done entirely through the administration\r
+application. This section describes how this works, you might also want to\r
+check the <A HREF="../Tutorials/configuration.html">configuration tutorial</A>.\r
+<P>\r
+When you connect to the <B>Jigsaw</B> admin server through the <B>JigAdm</B>\r
+application, you'll see that each opened server as a node named\r
+<I>indexers</I>. At installation time, this will only display the default\r
+indexer which knows about usual mime types.\r
+<P>\r
+Open the <I>default</I> indexer node, and its extension database. This will\r
+show up the sorted list of currently defined extensions. To remove an extension\r
+record, select it by clicking on its name, and press the <I>Delete Resource\r
+</I>button (bottom of the right panel): the extension record is deleted from\r
+the database. To edit a particular extension record, select it. On the top\r
+of the right panel you can see a number of buttons, click on the\r
+<I>Attributes</I> button.This will bring up a form, containing all the default\r
+attribute values for the extension. This form changes depending on the class\r
+that you have attached to the extension (extension with no class applies\r
+to all resources, hence, they allow you to edit the\r
+<A HREF="../Reference/w3c.jigsaw.resources.HTTPResource.html"><CODE>HTTPResource</CODE></A>\r
+attribute values). You can change any of these values, which will provided\r
+as default attribute values for resources wrapping a file that matches this\r
+particular extension.\r
+<P>\r
+To define new extensions, select the <I>extensions</I> node. This will popup\r
+a form querying you for the extension name (the <I>identifier</I> field at\r
+the top), and the class. Let's say you want to define the extension\r
+<CODE>ps</CODE> for exporting <B>application/postscript</B> files. Type in\r
+the name of the extension (here <CODE>ps</CODE>), and attach it the\r
+<CODE><A HREF="../Reference/w3c.jigsaw.resources.FileResource.html">w3c.jigsaw.resources.FileResource</A></CODE>\r
+class, then click on the <I>Add Resource&nbsp;</I>button. Select the newly\r
+created extension and click on the upper <I>Attributes</I> button. This will\r
+popup the attribute editor, state that the default value for the\r
+<CODE>content-type</CODE> is <B>application/postscript</B>, and press the\r
+<I>Commit</I> button. You are done: all files having the <CODE>ps</CODE>\r
+extension will be exported through a FileResource whose default value for\r
+the <CODE>content-type</CODE> attribute will be\r
+<B>application/postscript</B>.\r
+<P>\r
+Now, let's create some directory templates. Open the <I>directories</I> node.\r
+This will display the sorted list of currently defined templates. To remove\r
+a directory template, just select it , and press the <I>Delete Resource\r
+</I>button (at the bottom of the right panel). To edit the attributes of\r
+a directory template, click on its name, and select the <I>Attributes</I>\r
+sheet. This will display the set of attributes for the directory template\r
+itself. \r
+<P>\r
+  <HR>\r
+<BR>\r
+<A HREF="mailto:jigsaw@w3.org">Jigsaw Team</A><BR>\r
+$Id: indexer.html,v 1.1 2010/06/15 12:20:10 smhuang Exp $\r
+</BODY></HTML>\r