use of v7db.files.milton.MiltonServlet 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) {
}
}
}
Aggregations