Package org.acaro.dbpedia4neo.web

Source Code of org.acaro.dbpedia4neo.web.Main

package org.acaro.dbpedia4neo.web;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph;
import com.tinkerpop.blueprints.pgm.impls.sail.SailGraph;
import com.tinkerpop.blueprints.pgm.oupls.sail.GraphSail;

public class Main {
  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();
        }
      }
        });
        // start the server
        server.start();
        server.join()
  }
}
TOP

Related Classes of org.acaro.dbpedia4neo.web.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.