Search in sources :

Example 1 with BucketsServlet

use of v7db.files.buckets.BucketsServlet in project v7files by thiloplanz.

the class ServeCommand method main.

/**
	 * @param args
	 * @throws Exception
	 */
public static void main(String[] args) throws Exception {
    Configuration.checkEndpoints();
    ServletContextHandler handler = new ServletContextHandler();
    handler.setContextPath("/");
    // WebDAV
    {
        String[] endpoints = Configuration.getArrayProperty("webdav.endpoints");
        for (String endpoint : endpoints) {
            ServletHolder servlet = new ServletHolder(new MiltonServlet());
            servlet.setInitParameter("webdav.endpoint", endpoint);
            servlet.setInitParameter("resource.factory.factory.class", Configuration.getProperty("resource.factory.factory.class"));
            handler.addServlet(servlet, endpoint.equals("/") ? "/*" : (endpoint + "/*"));
        }
    }
    // Buckets
    {
        String[] endpoints = Configuration.getArrayProperty("buckets.endpoints");
        for (String endpoint : endpoints) {
            ServletHolder servlet = new ServletHolder(new BucketsServlet(Configuration.getEndpointProperties(endpoint)));
            handler.addServlet(servlet, endpoint.equals("/") ? "/*" : (endpoint + "/*"));
        }
    }
    int port = Integer.parseInt(Configuration.getProperty("http.port"));
    final Server server = new Server(port);
    server.setHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("failed to start HTTP server");
        try {
            server.stop();
        } catch (Exception f) {
            f.printStackTrace();
            System.exit(1);
        }
    }
    try {
        System.in.read();
        server.stop();
    } catch (IOException e) {
        System.err.println("STDIN unavailable, continue running in daemon mode");
        try {
            synchronized (args) {
                // forever
                args.wait();
            }
        } catch (InterruptedException e1) {
        }
    }
}
Also used : MiltonServlet(v7db.files.milton.MiltonServlet) Server(org.eclipse.jetty.server.Server) BucketsServlet(v7db.files.buckets.BucketsServlet) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) IOException(java.io.IOException) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Server (org.eclipse.jetty.server.Server)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 BucketsServlet (v7db.files.buckets.BucketsServlet)1 MiltonServlet (v7db.files.milton.MiltonServlet)1