it.unimi.dsi.mg4j.query
Class HttpQueryServer

java.lang.Object
  extended by it.unimi.dsi.mg4j.query.HttpQueryServer

public class HttpQueryServer
extends Object

A very basic HTTP server answering queries.

The main method of this class starts a very basic HTTP server answering queries. If a matching document collection is provided, the server will also display some intervals satisfying the queries.

Queries are served by the QueryServlet; by default, the servlet listen on port 4242, and the servlet is deployed under the path /Query. A servlet displaying single documents from the collection is deployed under the path /Item. The server and the servlet are fully multithreaded.

If you want to start this server from the command line, you must use the main method of Query, providing the suitable option. Changes to the QueryEngine made through the text interface will be reflected in the web interface, making it possible to experiment with different settings.

Warning: this server creates a Velocity instance with some default parameter: in particular, template resolution is performed first on the classpath, then relatively to the current directory, and finally using absolute pathnames. Watch out for template resolution issues.


Field Summary
 org.mortbay.http.HttpServer server
          The underlying Jetty server.
 
Constructor Summary
HttpQueryServer(QueryEngine queryEngine, DocumentCollection collection, Class<? extends HttpServlet> itemClass, String itemMimeType, int port, List<? extends CharSequence> titleList)
          Creates a new HTTP query server.
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

public final org.mortbay.http.HttpServer server
The underlying Jetty server. Access to this field is useful to tune or stop the server.

Constructor Detail

HttpQueryServer

public HttpQueryServer(QueryEngine queryEngine,
                       DocumentCollection collection,
                       Class<? extends HttpServlet> itemClass,
                       String itemMimeType,
                       int port,
                       List<? extends CharSequence> titleList)
                throws Exception
Creates a new HTTP query server.

Parameters:
queryEngine - the query engine that will be used (actually, copied) by the servlets run by this query server.
collection - the document collection (related to the indices contained in queryEngine) that will be used to display documents.
itemClass - a class implementing an HttpServlet and responsible for displaying documents (see, e.g., GenericItem.
itemMimeType - the default MIME type of a displayed item.
port - the port exposing the server.
titleList - an optional list of titles for all documents, or null.
Throws:
Exception