More honest about SRU/SRW support.
[metaproxy-moved-to-github.git] / doc / book.xml
1 <!-- $Id: book.xml,v 1.7 2006-04-19 16:01:41 mike Exp $ -->
2  <bookinfo>
3   <title>Metaproxy - User's Guide and Reference</title>
4   <author>
5    <firstname>Mike</firstname><surname>Taylor</surname>
6   </author>
7   <author>
8    <firstname>Adam</firstname><surname>Dickmeiss</surname>
9   </author>
10   <copyright>
11    <year>2006</year>
12    <holder>Index Data</holder>
13   </copyright>
14   <abstract>
15    <simpara>
16     Metaproxy is a universal router, proxy and encapsulated
17     metasearcher for information retrieval protocols.  It accepts,
18     processes, interprets and redirects requests from IR clients using
19     standard protocols such as ANSI/NISO Z39.50 (and in the future SRU
20     and SRW), as well as functioning as a limited
21     HTTP server.  Metaproxy is configured by an XML file which
22     specifies how the software should function in terms of routes that
23     the request packets can take through the proxy, each step on a
24     route being an instantiation of a filter.  Filters come in many
25     types, one for each operation: accepting Z39.50 packets, logging,
26     query transformation, multiplexing, etc.  Further filter-types can
27     be added as loadable modules to extend Metaproxy functionality,
28     using the filter API.
29    </simpara>
30    <simpara>
31     The terms under which Metaproxy will be distributed have yet to be
32     established, but it will not necessarily be open source; so users
33     should not at this stage redistribute the code without explicit
34     written permission from the copyright holders, Index Data ApS.
35    </simpara>
36   </abstract>
37  </bookinfo>
38
39  <chapter id="introduction">
40   <title>Introduction</title>
41   
42   
43    <para>
44     <ulink url="http://indexdata.dk/metaproxy/">Metaproxy</ulink>
45     is a standalone program that acts as a universal router, proxy and
46     encapsulated metasearcher for information retrieval protocols such
47     as Z39.50, and in the future SRU and SRW.  To clients, it acts as a
48     server of these
49     protocols: it can be searched, records can be retrieved from it,
50     etc.  To servers, it acts as a client: it searches in them,
51     retrieves records from them, etc.  it satisfies its clients'
52     requests by transforming them, multiplexing them, forwarding them
53     on to zero or more servers, merging the results, transforming
54     them, and delivering them back to the client.  In addition, it
55     acts as a simple HTTP server; support for further protocols can be
56     added in a module fashion, through the creation of new filters.
57    </para>
58    <screen>
59     Anything goes in!
60     Anything goes out!
61     Cold bananas, fish, pyjamas,
62     Mutton, beef and trout!
63         - attributed to Cole Porter.
64    </screen>
65    <para>
66     Metaproxy is a more capable alternative to
67     <ulink url="http://indexdata.dk/yazproxy/">YAZ Proxy</ulink>,
68     being more powerful, flexible, configurable and extensible.  Among
69     its many advantages over the older, more pedestrian work are
70     support for multiplexing (encapsulated metasearching), routing by
71     database name, authentication and authorisation and serving local
72     files via HTTP.  Equally significant, its modular architecture
73     facilitites the creation of pluggable modules implementing further
74     functionality.
75    </para>
76  </chapter>
77
78
79
80  <chapter id="licence">
81   <title>The Metaproxy Licence</title>
82   <para>
83    <emphasis role="strong">
84      No decision has yet been made on the terms under which
85      Metaproxy will be distributed.
86    </emphasis>
87    It is possible that, unlike
88    other Index Data products, metaproxy may not be released under a
89    free-software licence such as the GNU GPL.  Until a decision is
90    made and a public statement made, then, and unless it has been
91    delivered to you other specific terms, please treat Metaproxy as
92    though it were proprietary software.
93    The code should not be redistributed without explicit
94    written permission from the copyright holders, Index Data ApS.
95   </para>
96  </chapter>
97
98
99
100  <chapter id="architecture">
101   <title>The Metaproxy Architecture</title>
102   <para>
103    The Metaproxy architecture is based on three concepts:
104    the <emphasis>package</emphasis>,
105    the <emphasis>route</emphasis>
106    and the <emphasis>filter</emphasis>.
107   </para>
108   <variablelist>
109    <varlistentry>
110     <term>Packages</term>
111     <listitem>
112      <para>
113       A package is request or response, encoded in some protocol,
114       issued by a client, making its way through Metaproxy, send to or
115       received from a server, or sent back to the client.
116      </para>
117      <para>
118       The core of a package is the protocol unit - for example, a
119       Z39.50 Init Request or Search Response, or an SRU searchRetrieve
120       URL or Explain Response.  In addition to this core, a package
121       also carries some extra information added and used by Metaproxy
122       itself.
123      </para>
124      <para>
125       In general, packages are doctored as they pass through
126       Metaproxy.  For example, when the proxy performs authentication
127       and authorisation on a Z39.50 Init request, it removes the
128       authentication credentials from the package so that they are not
129       passed onto the back-end server; and when search-response
130       packages are obtained from multiple servers, they are merged
131       into a single unified package that makes its way back to the
132       client.
133      </para>
134     </listitem>
135    </varlistentry>
136    <varlistentry>
137     <term>Routes</term>
138     <listitem>
139      <para>
140       Packages make their way through routes, which can be thought of
141       as programs that operate on the package data-type.  Each
142       incoming package initially makes its way through a default
143       route, but may be switched to a different route based on various
144       considerations.  Routes are made up of sequences of filters (see
145       below).
146      </para>
147     </listitem>
148    </varlistentry>
149    <varlistentry>
150     <term>Filters</term>
151     <listitem>
152      <para>
153       Filters provide the individual instructions within a route, and
154       effect the necessary transformations on packages.  A particular
155       configuration of Metaproxy is essentially a set of filters,
156       described by configuration details and arranged in order in one
157       or more routes.  There are many kinds of filter - about a dozen
158       at the time of writing with more appearing all the time - each
159       performing a specific function and configured by different
160       information.
161      </para>
162      <para>
163       The word ``filter'' is sometimes used rather loosely, in two
164       different ways: it may be used to mean a particular
165       <emphasis>type</emphasis> of filter, as when we speak of ``the
166       auth_simplefilter'' or ``the multi filter''; or it may be used
167       to be a specific <emphasis>instance</emphasis> of a filter
168       within a Metaproxy configuration.  For example, a single
169       configuration will often contain multiple instances of the
170       <literal>z3950_client</literal> filter.  In
171       operational terms, of these is a separate filter.  In practice,
172       context always make it clear which sense of the word ``filter''
173       is being used.
174      </para>
175      <para>
176       Extensibility of Metaproxy is primarily through the creation of
177       plugins that provide new filters.  The filter API is small and
178       conceptually simple, but there are many details to master.  See
179       the section below on
180       <link linkend="extensions">extensions</link>.
181      </para>
182     </listitem>
183    </varlistentry>
184   </variablelist>
185   <para>
186    Since packages are created and handled by the system itself, and
187    routes are conceptually simple, most of the remainder of this
188    document concentrates on filters.  After a brief overview of the
189    filter types follows, along with some thoughts on possible future
190    directions.
191   </para>
192  </chapter>
193
194
195
196  <chapter id="filters">
197   <title>Filters</title>
198   
199   
200   <section>
201    <title>Introductory notes</title>
202    <para>
203     It's useful to think of Metaproxy as an interpreter providing a small
204     number of primitives and operations, but operating on a very
205     complex data type, namely the ``package''.
206    </para>
207    <para>
208     A package represents a Z39.50 or SRU/W request (whether for Init,
209     Search, Scan, etc.)  together with information about where it came
210     from.  Packages are created by front-end filters such as
211     <literal>frontend_net</literal> (see below), which reads them from
212     the network; other front-end filters are possible.  They then pass
213     along a route consisting of a sequence of filters, each of which
214     transforms the package and may also have side-effects such as
215     generating logging.  Eventually, the route will yield a response,
216     which is sent back to the origin.
217    </para>
218    <para>
219     There are many kinds of filter: some that are defined statically
220     as part of Metaproxy, and others may be provided by third parties
221     and dynamically loaded.  They all conform to the same simple API
222     of essentially two methods: <function>configure()</function> is
223     called at startup time, and is passed a DOM tree representing that
224     part of the configuration file that pertains to this filter
225     instance: it is expected to walk that tree extracting relevant
226     information; and <function>process()</function> is called every
227     time the filter has to processes a package.
228    </para>
229    <para>
230     While all filters provide the same API, there are different modes
231     of functionality.  Some filters are sources: they create
232     packages
233     (<literal>frontend_net</literal>);
234     others are sinks: they consume packages and return a result
235     (<literal>z3950_client</literal>,
236     <literal>backend_test</literal>,
237     <literal>http_file</literal>);
238     the others are true filters, that read, process and pass on the
239     packages they are fed
240     (<literal>auth_simple</literal>,
241     <literal>log</literal>,
242     <literal>multi</literal>,
243     <literal>query_rewrite</literal>,
244     <literal>session_shared</literal>,
245     <literal>template</literal>,
246     <literal>virt_db</literal>).
247    </para>
248  </section>
249   
250   
251   <section>
252    <title>Overview of filter types</title>
253    <para>
254     We now briefly consider each of the types of filter supported by
255     the core Metaproxy binary.  This overview is intended to give a
256     flavour of the available functionality; more detailed information
257     about each type of filter is included below in the Module
258     Reference.
259    </para>
260    <para>
261     The filters are here named by the string that is used as the
262     <literal>type</literal> attribute of a
263     <literal>&lt;filter&gt;</literal> element in the configuration
264     file to request them, with the name of the class that implements
265     them in parentheses.  (The classname is not needed for normal
266     configuration and use of Metaproxy; it is useful only to
267     developers.)
268    </para>
269    <para>
270     The filters are here listed in alphabetical order:
271    </para>
272    
273    <section>
274     <title><literal>auth_simple</literal>
275      (mp::filter::AuthSimple)</title>
276     <para>
277      Simple authentication and authorisation.  The configuration
278      specifies the name of a file that is the user register, which
279      lists <varname>username</varname>:<varname>password</varname>
280      pairs, one per line, colon separated. When a session begins, it
281      is rejected unless username and passsword are supplied, and match
282      a pair in the register.  The configuration file may also specific
283      the name of another file that is the target register: this lists
284      lists <varname>username</varname>:<varname>dbname</varname>,<varname>dbname</varname>...
285      sets, one per line, with multiple database names separated by
286      commas.  When a search is processed, it is rejected unless the
287      database to be searched is one of those listed as available to
288      the user.
289     </para>
290    </section>
291    
292    <section>
293     <title><literal>backend_test</literal>
294     (mp::filter::Backend_test)</title>
295     <para>
296      A sink that provides dummy responses in the manner of the
297      <literal>yaz-ztest</literal> Z39.50 server.  This is useful only
298      for testing.  Seriously, you don't need this.  Pretend you didn't
299      even read this section.
300     </para>
301    </section>
302    
303    <section>
304     <title><literal>frontend_net</literal>
305      (mp::filter::FrontendNet)</title>
306     <para>
307      A source that accepts Z39.50 connections from a port
308      specified in the configuration, reads protocol units, and
309      feeds them into the next filter in the route.  When the result is
310      revceived, it is returned to the original origin.
311     </para>
312    </section>
313
314    <section>
315     <title><literal>http_file</literal>
316      (mp::filter::HttpFile)</title>
317     <para>
318      A sink that returns the contents of files from the local
319      filesystem in response to HTTP requests.  (Yes, Virginia, this
320      does mean that Metaproxy is also a Web-server in its spare time.  So
321      far it does not contain either an email-reader or a Lisp
322      interpreter, but that day is surely coming.)
323     </para>
324    </section>
325    
326    <section>
327     <title><literal>log</literal>
328      (mp::filter::Log)</title>
329     <para>
330      Writes logging information to standard output, and passes on
331      the package unchanged.
332    </para>
333    </section>
334    
335    <section>
336    <title><literal>multi</literal>
337      (mp::filter::Multi)</title>
338     <para>
339      Performs multicast searching.
340      See
341      <link linkend="multidb">the extended discussion</link>
342      of virtual databases and multi-database searching below.
343     </para>
344    </section>
345    
346    <section>
347    <title><literal>query_rewrite</literal>
348      (mp::filter::QueryRewrite)</title>
349     <para>
350      Rewrites Z39.50 Type-1 and Type-101 (``RPN'') queries by a
351      three-step process: the query is transliterated from Z39.50
352      packet structures into an XML representation; that XML
353      representation is transformed by an XSLT stylesheet; and the
354      resulting XML is transliterated back into the Z39.50 packet
355      structure.
356     </para>
357    </section>
358    
359    <section>
360     <title><literal>session_shared</literal>
361      (mp::filter::SessionShared)</title>
362     <para>
363      When this is finished, it will implement global sharing of
364      result sets (i.e. between threads and therefore between
365      clients), yielding performance improvements especially when
366      incoming requests are from a stateless environment such as a
367      web-server, in which the client process representing a session
368      might be any one of many.  However:
369     </para>
370     <warning>
371      <para>
372       This filter is not yet completed.
373      </para>
374     </warning>
375    </section>
376    
377    <section>
378     <title><literal>template</literal>
379      (mp::filter::Template)</title>
380     <para>
381      Does nothing at all, merely passing the packet on.  (Maybe it
382      should be called <literal>nop</literal> or
383      <literal>passthrough</literal>?)  This exists not to be used, but
384      to be copied - to become the skeleton of new filters as they are
385      written.  As with <literal>backend_test</literal>, this is not
386      intended for civilians.
387     </para>
388    </section>
389    
390    <section>
391     <title><literal>virt_db</literal>
392      (mp::filter::Virt_db)</title>
393     <para>
394      Performs virtual database selection: based on the name of the
395      database in the search request, a server is selected, and its
396      address added to the request in a <literal>VAL_PROXY</literal>
397      otherInfo packet.  It will subsequently be used by a
398      <literal>z3950_client</literal> filter.
399      See
400      <link linkend="multidb">the extended discussion</link>
401      of virtual databases and multi-database searching below.
402     </para>
403    </section>
404    
405    <section>
406     <title><literal>z3950_client</literal>
407      (mp::filter::Z3950Client)</title>
408     <para>
409      Performs Z39.50 searching and retrieval by proxying the
410      packages that are passed to it.  Init requests are sent to the
411      address specified in the <literal>VAL_PROXY</literal> otherInfo
412      attached to the request: this may have been specified by client,
413      or generated by a <literal>virt_db</literal> filter earlier in
414      the route.  Subsequent requests are sent to the same address,
415      which is remembered at Init time in a Session object.
416     </para>
417   </section>
418   </section>
419   
420   
421   <section>
422    <title>Future directions</title>
423   <para>
424     Some other filters that do not yet exist, but which would be
425     useful, are briefly described.  These may be added in future
426     releases (or may be created by third parties, as loadable
427     modules).
428    </para>
429
430    <variablelist>
431     <varlistentry>
432      <term><literal>frontend_cli</literal> (source)</term>
433     <listitem>
434       <para>
435        Command-line interface for generating requests.
436       </para>
437      </listitem>
438     </varlistentry>
439     <varlistentry>
440      <term><literal>frontend_sru</literal> (source)</term>
441      <listitem>
442       <para>
443        Receive SRU (and perhaps SRW) requests.
444      </para>
445      </listitem>
446     </varlistentry>
447     <varlistentry>
448      <term><literal>sru2z3950</literal> (filter)</term>
449      <listitem>
450       <para>
451        Translate SRU requests into Z39.50 requests.
452      </para>
453      </listitem>
454     </varlistentry>
455     <varlistentry>
456      <term><literal>sru_client</literal> (sink)</term>
457      <listitem>
458       <para>
459        SRU searching and retrieval.
460       </para>
461      </listitem>
462     </varlistentry>
463     <varlistentry>
464      <term><literal>srw_client</literal> (sink)</term>
465      <listitem>
466       <para>
467        SRW searching and retrieval.
468       </para>
469      </listitem>
470     </varlistentry>
471     <varlistentry>
472      <term><literal>opensearch_client</literal> (sink)</term>
473      <listitem>
474       <para>
475        A9 OpenSearch searching and retrieval.
476       </para>
477      </listitem>
478     </varlistentry>
479    </variablelist>
480   </section>
481  </chapter>
482  
483  
484  
485  <chapter id="multidb">
486   <title>Virtual databases and multi-database searching</title>
487
488
489   <section>
490    <title>Introductory notes</title>
491    <para>
492     Two of Metaproxy's filters are concerned with multiple-database
493     operations.  Of these, <literal>virt_db</literal> can work alone
494     to control the routing of searches to one of a number of servers,
495     while <literal>multi</literal> can work with the output of
496     <literal>virt_db</literal> to perform multicast searching, merging
497     the results into a unified result-set.  The interaction between
498     these two filters is necessarily complex, reflecting the real
499     complexity of multicast searching in a protocol such as Z39.50
500     that separates initialisation from searching, with the database to
501     search known only during the latter operation.
502    </para>
503    <para>
504     ### Much, much more to say!
505    </para>
506   </section>
507  </chapter>
508
509
510
511  <chapter id="configuration">
512   <title>Configuration: the Metaproxy configuration file format</title>
513   
514   
515   <section>
516    <title>Introductory notes</title>
517    <para>
518     If Metaproxy is an interpreter providing operations on packages, then
519     its configuration file can be thought of as a program for that
520     interpreter.  Configuration is by means of a single file, the name
521     of which is supplied as the sole command-line argument to the
522     <command>yp2</command> program.
523    </para>
524    <para>
525     The configuration files are written in XML.  (But that's just an
526     implementation detail - they could just as well have been written
527     in YAML or Lisp-like S-expressions, or in a custom syntax.)
528    </para>
529    <para>
530     Since XML has been chosen, an XML schema,
531     <filename>config.xsd</filename>, is provided for validating
532     configuration files.  This file is supplied in the
533     <filename>etc</filename> directory of the Metaproxy distribution.  It
534     can be used by (among other tools) the <command>xmllint</command>
535     program supplied as part of the <literal>libxml2</literal>
536     distribution:
537    </para>
538    <screen>
539     xmllint --noout --schema etc/config.xsd my-config-file.xml
540    </screen>
541    <para>
542     (A recent version of <literal>libxml2</literal> is required, as
543     support for XML Schemas is a relatively recent addition.)
544    </para>
545   </section>
546   
547   <section>
548    <title>Overview of XML structure</title>
549    <para>
550     All elements and attributes are in the namespace
551     <ulink url="http://indexdata.dk/yp2/config/1"/>.
552      This is most easily achieved by setting the default namespace on
553      the top-level element, as here:
554    </para>
555    <screen>
556     &lt;yp2 xmlns="http://indexdata.dk/yp2/config/1"&gt;
557    </screen>
558    <para>
559     The top-level element is &lt;yp2&gt;.  This contains a
560     &lt;start&gt; element, a &lt;filters&gt; element and a
561     &lt;routes&gt; element, in that order.  &lt;filters&gt; is
562     optional; the other two are mandatory.  All three are
563     non-repeatable.
564    </para>
565   <para>
566     The &lt;start&gt; element is empty, but carries a
567     <literal>route</literal> attribute, whose value is the name of
568     route at which to start running - analogouse to the name of the
569     start production in a formal grammar.
570    </para>
571   <para>
572     If present, &lt;filters&gt; contains zero or more &lt;filter&gt;
573     elements; filters carry a <literal>type</literal> attribute and
574     contain various elements that provide suitable configuration for
575     filters of that type.  The filter-specific elements are described
576     below.  Filters defined in this part of the file must carry an
577     <literal>id</literal> attribute so that they can be referenced
578     from elsewhere.
579    </para>
580    <para>
581     &lt;routes&gt; contains one or more &lt;route&gt; elements, each
582     of which must carry an <literal>id</literal> element.  One of the
583     routes must have the ID value that was specified as the start
584     route in the &lt;start&gt; element's <literal>route</literal>
585     attribute.  Each route contains zero or more &lt;filter&gt;
586     elements.  These are of two types.  They may be empty, but carry a
587     <literal>refid</literal> attribute whose value is the same as the
588     <literal>id</literal> of a filter previously defined in the
589     &lt;filters&gt; section.  Alternatively, a route within a filter
590     may omit the <literal>refid</literal> attribute, but contain
591     configuration elements similar to those used for filters defined
592     in the &lt;filters&gt; section.
593    </para>
594   </section>
595
596
597   <section>
598    <title>Filter configuration</title>
599    <para>
600     All &lt;filter&gt; elements have in common that they must carry a
601     <literal>type</literal> attribute whose value is one of the
602     supported ones, listed in the schema file and discussed below.  In
603     additional, &lt;filters&gt;s occurring the &lt;filters&gt; section
604     must have an <literal>id</literal> attribute, and those occurring
605     within a route must have either a <literal>refid</literal>
606     attribute referencing a previously defined filter or contain its
607     own configuration information.
608    </para>
609    <para>
610     In general, each filter recognises different configuration
611     elements within its element, as each filter has different
612     functionality.  These are as follows:
613    </para>
614
615    <section>
616     <title><literal>auth_simple</literal></title>
617     <screen>
618      &lt;filter type="auth_simple"&gt;
619      &lt;userRegister&gt;../etc/example.simple-auth&lt;/userRegister&gt;
620      &lt;/filter&gt;
621     </screen>
622    </section>
623
624    <section>
625     <title><literal>backend_test</literal></title>
626     <screen>
627      &lt;filter type="backend_test"/&gt;
628     </screen>
629    </section>
630
631    <section>
632     <title><literal>frontend_net</literal></title>
633     <screen>
634      &lt;filter type="frontend_net"&gt;
635      &lt;threads&gt;10&lt;/threads&gt;
636      &lt;port&gt;@:9000&lt;/port&gt;
637      &lt;/filter&gt;
638     </screen>
639    </section>
640
641    <section>
642     <title><literal>http_file</literal></title>
643     <screen>
644      &lt;filter type="http_file"&gt;
645      &lt;mimetypes&gt;/etc/mime.types&lt;/mimetypes&gt;
646      &lt;area&gt;
647      &lt;documentroot&gt;.&lt;/documentroot&gt;
648      &lt;prefix&gt;/etc&lt;/prefix&gt;
649      &lt;/area&gt;
650      &lt;/filter&gt;
651     </screen>
652    </section>
653
654    <section>
655     <title><literal>log</literal></title>
656     <screen>
657      &lt;filter type="log"&gt;
658      &lt;message&gt;B&lt;/message&gt;
659      &lt;/filter&gt;
660     </screen>
661    </section>
662
663    <section>
664     <title><literal>multi</literal></title>
665     <screen>
666      &lt;filter type="multi"/&gt;
667     </screen>
668    </section>
669
670    <section>
671     <title><literal>query_rewrite</literal></title>
672     <screen>
673      &lt;filter type="query_rewrite"&gt;
674      &lt;xslt&gt;pqf2pqf.xsl&lt;/xslt&gt;
675      &lt;/filter&gt;
676     </screen>
677    </section>
678
679    <section>
680     <title><literal>session_shared</literal></title>
681     <screen>
682      &lt;filter type="session_shared"&gt;
683      ### Not yet defined
684      &lt;/filter&gt;
685     </screen>
686    </section>
687
688    <section>
689     <title><literal>template</literal></title>
690     <screen>
691      &lt;filter type="template"/&gt;
692     </screen>
693    </section>
694
695    <section>
696     <title><literal>virt_db</literal></title>
697     <screen>
698      &lt;filter type="virt_db"&gt;
699      &lt;virtual&gt;
700      &lt;database&gt;loc&lt;/database&gt;
701      &lt;target&gt;z3950.loc.gov:7090/voyager&lt;/target&gt;
702      &lt;/virtual&gt;
703      &lt;virtual&gt;
704      &lt;database&gt;idgils&lt;/database&gt;
705      &lt;target&gt;indexdata.dk/gils&lt;/target&gt;
706      &lt;/virtual&gt;
707      &lt;/filter&gt;
708     </screen>
709    </section>
710
711    <section>
712     <title><literal>z3950_client</literal></title>
713     <screen>
714      &lt;filter type="z3950_client"&gt;
715      &lt;timeout&gt;30&lt;/timeout&gt;
716      &lt;/filter&gt;
717     </screen>
718    </section>
719   </section>
720  </chapter>
721
722
723
724  <chapter id="moduleref">
725   <title>Module Reference</title>
726   <para>
727    The material in this chapter includes the man pages material
728   </para>
729   &manref;
730  </chapter>
731
732  <chapter id="extensions">
733   <title>Writing extensions for Metaproxy</title>
734   <para>###</para>
735  </chapter>
736
737  <chapter id="classes">
738   <title>Classes in the Metaproxy source code</title>
739
740
741   <section>
742    <title>Introductory notes</title>
743    <para>
744     <emphasis>Stop!  Do not read this!</emphasis>
745     You won't enjoy it at all.
746    </para>
747    <para>
748     This chapter contains documentation of the Metaproxy source code, and is
749     of interest only to maintainers and developers.  If you need to
750     change Metaproxy's behaviour or write a new filter, then you will most
751     likely find this chapter helpful.  Otherwise it's a waste of your
752     good time.  Seriously: go and watch a film or something.
753     <citetitle>This is Spinal Tap</citetitle> is particularly good.
754    </para>
755    <para>
756     Still here?  OK, let's continue.
757    </para>
758    <para>
759     In general, classes seem to be named big-endianly, so that
760     <literal>FactoryFilter</literal> is not a filter that filters
761     factories, but a factory that produces filters; and
762     <literal>FactoryStatic</literal> is a factory for the statically
763     registered filters (as opposed to those that are dynamically
764     loaded).
765    </para>
766   </section>
767
768   <section>
769    <title>Individual classes</title>
770    <para>
771     The classes making up the Metaproxy application are here listed by
772     class-name, with the names of the source files that define them in
773     parentheses.
774    </para>
775
776    <section>
777     <title><literal>mp::FactoryFilter</literal>
778      (<filename>factory_filter.cpp</filename>)</title>
779     <para>
780      A factory class that exists primarily to provide the
781      <literal>create()</literal> method, which takes the name of a
782      filter class as its argument and returns a new filter of that
783      type.  To enable this, the factory must first be populated by
784      calling <literal>add_creator()</literal> for static filters (this
785      is done by the <literal>FactoryStatic</literal> class, see below)
786      and <literal>add_creator_dyn()</literal> for filters loaded
787      dynamically.
788     </para>
789    </section>
790
791    <section>
792     <title><literal>mp::FactoryStatic</literal>
793      (<filename>factory_static.cpp</filename>)</title>
794     <para>
795      A subclass of <literal>FactoryFilter</literal> which is
796      responsible for registering all the statically defined filter
797      types.  It does this by knowing about all those filters'
798      structures, which are listed in its constructor.  Merely
799      instantiating this class registers all the static classes.  It is
800      for the benefit of this class that <literal>struct
801       yp2_filter_struct</literal> exists, and that all the filter
802      classes provide a static object of that type.
803     </para>
804    </section>
805
806    <section>
807     <title><literal>mp::filter::Base</literal>
808      (<filename>filter.cpp</filename>)</title>
809     <para>
810      The virtual base class of all filters.  The filter API is, on the
811      surface at least, extremely simple: two methods.
812      <literal>configure()</literal> is passed a DOM tree representing
813      that part of the configuration file that pertains to this filter
814      instance, and is expected to walk that tree extracting relevant
815      information.  And <literal>process()</literal> processes a
816      package (see below).  That surface simplicitly is a bit
817      misleading, as <literal>process()</literal> needs to know a lot
818      about the <literal>Package</literal> class in order to do
819      anything useful.
820     </para>
821    </section>
822
823    <section>
824     <title><literal>mp::filter::AuthSimple</literal>,
825      <literal>Backend_test</literal>, etc.
826      (<filename>filter_auth_simple.cpp</filename>,
827      <filename>filter_backend_test.cpp</filename>, etc.)</title>
828     <para>
829      Individual filters.  Each of these is implemented by a header and
830      a source file, named <filename>filter_*.hpp</filename> and
831      <filename>filter_*.cpp</filename> respectively.  All the header
832      files should be pretty much identical, in that they declare the
833      class, including a private <literal>Rep</literal> class and a
834      member pointer to it, and the two public methods.  The only extra
835      information in any filter header is additional private types and
836      members (which should really all be in the <literal>Rep</literal>
837      anyway) and private methods (which should also remain known only
838      to the source file, but C++'s brain-damaged design requires this
839      dirty laundry to be exhibited in public.  Thanks, Bjarne!)
840     </para>
841     <para>
842      The source file for each filter needs to supply:
843     </para>
844     <itemizedlist>
845      <listitem>
846       <para>
847        A definition of the private <literal>Rep</literal> class.
848       </para>
849      </listitem>
850      <listitem>
851       <para>
852        Some boilerplate constructors and destructors.
853       </para>
854      </listitem>
855      <listitem>
856       <para>
857        A <literal>configure()</literal> method that uses the
858        appropriate XML fragment.
859       </para>
860      </listitem>
861      <listitem>
862       <para>
863        Most important, the <literal>process()</literal> method that
864        does all the actual work.
865       </para>
866      </listitem>
867     </itemizedlist>
868    </section>
869
870    <section>
871     <title><literal>mp::Package</literal>
872      (<filename>package.cpp</filename>)</title>
873     <para>
874      Represents a package on its way through the series of filters
875      that make up a route.  This is essentially a Z39.50 or SRU APDU
876      together with information about where it came from, which is
877      modified as it passes through the various filters.
878     </para>
879    </section>
880
881    <section>
882     <title><literal>mp::Pipe</literal>
883      (<filename>pipe.cpp</filename>)</title>
884     <para>
885      This class provides a compatibility layer so that we have an IPC
886      mechanism that works the same under Unix and Windows.  It's not
887      particularly exciting.
888     </para>
889    </section>
890
891    <section>
892     <title><literal>mp::RouterChain</literal>
893      (<filename>router_chain.cpp</filename>)</title>
894     <para>
895      ###
896     </para>
897    </section>
898
899    <section>
900     <title><literal>mp::RouterFleXML</literal>
901      (<filename>router_flexml.cpp</filename>)</title>
902     <para>
903      ###
904     </para>
905    </section>
906
907    <section>
908     <title><literal>mp::Session</literal>
909      (<filename>session.cpp</filename>)</title>
910     <para>
911      ###
912     </para>
913    </section>
914
915    <section>
916     <title><literal>mp::ThreadPoolSocketObserver</literal>
917      (<filename>thread_pool_observer.cpp</filename>)</title>
918     <para>
919      ###
920     </para>
921    </section>
922
923    <section>
924     <title><literal>mp::util</literal>
925      (<filename>util.cpp</filename>)</title>
926     <para>
927      A namespace of various small utility functions and classes,
928      collected together for convenience.  Most importantly, includes
929      the <literal>mp::util::odr</literal> class, a wrapper for YAZ's
930      ODR facilities.
931     </para>
932    </section>
933
934    <section>
935     <title><literal>mp::xml</literal>
936      (<filename>xmlutil.cpp</filename>)</title>
937     <para>
938      A namespace of various XML utility functions and classes,
939      collected together for convenience.
940     </para>
941    </section>
942   </section>
943
944
945   <section>
946    <title>Other Source Files</title>
947    <para>
948     In addition to the Metaproxy source files that define the classes
949     described above, there are a few additional files which are
950     briefly described here:
951    </para>
952    <variablelist>
953     <varlistentry>
954      <term><literal>metaproxy_prog.cpp</literal></term>
955      <listitem>
956       <para>
957        The main function of the <command>yp2</command> program.
958       </para>
959      </listitem>
960     </varlistentry>
961     <varlistentry>
962      <term><literal>ex_router_flexml.cpp</literal></term>
963      <listitem>
964       <para>
965        Identical to <literal>metaproxy_prog.cpp</literal>: it's not clear why.
966       </para>
967      </listitem>
968     </varlistentry>
969     <varlistentry>
970      <term><literal>test_*.cpp</literal></term>
971      <listitem>
972       <para>
973        Unit-tests for various modules.
974       </para>
975      </listitem>
976     </varlistentry>
977    </variablelist>
978    <para>
979     ### Still to be described:
980     <literal>ex_filter_frontend_net.cpp</literal>,
981     <literal>filter_dl.cpp</literal>,
982     <literal>plainfile.cpp</literal>,
983     <literal>tstdl.cpp</literal>.
984    </para>
985    
986    
987    <!-- Epilogue -->
988    <para>
989     --
990    </para>
991    <screen>
992     <!-- This is just a lame way to get some vertical whitespace at
993     the end of the document -->
994     
995     
996     
997     
998    </screen>
999   </section>
1000  </chapter>
1001
1002  <!-- Keep this comment at the end of the file
1003  Local variables:
1004  mode: sgml
1005  sgml-omittag:t
1006  sgml-shorttag:t
1007  sgml-minimize-attributes:nil
1008  sgml-always-quote-attributes:t
1009  sgml-indent-step:1
1010  sgml-indent-data:t
1011  sgml-parent-document: "main.xml"
1012  sgml-local-catalogs: nil
1013  sgml-namecase-general:t
1014  nxml-child-indent: 1
1015  End:
1016  -->