it.unimi.di.mg4j.query
Class HttpFileServer

java.lang.Object
  extended by it.unimi.di.mg4j.query.HttpFileServer

public class HttpFileServer
extends Object

A minimal, singleton server serving the whole filesystem.

For security reasons, some browsers (notably Firefox at the time of this writing) do not serve file: content from a non-file: page. The solution is a minimal server that has the root of the filesystem as document root.

To instantiate the server, you just need a variable of type HttpFileServer. just retrieve and cache the result of getServer() (to avoid class garbage collection). A port is randomly assigned to the server; it can be retrieved with getPort(). In case you need a specific port, the system property it.unimi.di.mg4j.query.HttpFileServer.port can be used to this purpose.

It may happen that the server is not yet started when you call getPort(), in which case an IllegalStateException will be thrown.


Method Summary
static int getPort()
          Returns the port assigned to the server.
static HttpFileServer getServer()
          Returns the only instance of an HTTP file server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getServer

public static HttpFileServer getServer()
Returns the only instance of an HTTP file server.

Note that the instance should be cached by the application, to avoid garbage collection.

Returns:
the only instance of an HTTP file server

getPort

public static int getPort()
Returns the port assigned to the server.

Returns:
the port assigned to the server.