public class JSONWebServer extends Object implements com.sun.net.httpserver.HttpHandler
Modifier and Type | Field and Description |
---|---|
private Database |
db
The database we use for obtaining object bundles
|
protected static Logging |
logger
Our logger
|
static String |
PATH_JSON
The base path we serve data from
|
private HierarchicalResult |
result
The result tree we serve
|
private com.sun.net.httpserver.HttpServer |
server
Server instance
|
Constructor and Description |
---|
JSONWebServer(int port,
HierarchicalResult result)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
bundleToJSON(JSONBuffer re,
DBID id)
Serialize an object bundle to JSON.
|
void |
handle(com.sun.net.httpserver.HttpExchange exchange) |
private void |
outlierMetaToJSON(JSONBuffer re,
OutlierScoreMeta meta)
Serialize outlier metadata as JSON.
|
protected void |
resultToJSON(JSONBuffer re,
String name)
Serialize an arbitrary result into JSON.
|
void |
stop()
Stop the web server.
|
private DBID |
stringToDBID(String query)
Parse a string into a DBID.
|
protected static final Logging logger
public static final String PATH_JSON
private com.sun.net.httpserver.HttpServer server
private HierarchicalResult result
private Database db
public JSONWebServer(int port, HierarchicalResult result)
port
- Port to listen onresult
- Result to servepublic void stop()
private DBID stringToDBID(String query)
query
- Query stringprotected void bundleToJSON(JSONBuffer re, DBID id)
re
- Buffer to serialize toid
- Object IDprotected void resultToJSON(JSONBuffer re, String name)
re
- Buffer to serialize toname
- Result requestedprivate void outlierMetaToJSON(JSONBuffer re, OutlierScoreMeta meta)
re
- Output buffermeta
- Metadatapublic void handle(com.sun.net.httpserver.HttpExchange exchange) throws IOException
handle
in interface com.sun.net.httpserver.HttpHandler
IOException