public static void main(String[] args) throws Exception {
final Server server = new Server(8081);
final Neo4jGraph neo = new Neo4jGraph("dbpedia4neo");
final GraphSail gsail = new GraphSail(neo);
final SailGraph sail = new SailGraph(gsail);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
// set the query handler
context.addServlet(new ServletHolder(new QueryHandler(sail)), "/query");
// we need a clean shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
System.out.println("Shutting down...");
server.stop();
sail.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
});