Class HttpFileServer
- java.lang.Object
-
- it.unimi.di.big.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 ofgetServer()(to avoid class garbage collection). A port is randomly assigned to the server; it can be retrieved withgetPort(). In case you need a specific port, the system property it.unimi.di.big.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 anIllegalStateExceptionwill be thrown.
-
-
Method Summary
Modifier and Type Method Description static intgetPort()Returns the port assigned to the server.static HttpFileServergetServer()Returns the only instance of an HTTP file server.
-
-
-
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.
-
-