Search in sources :

Example 31 with HttpHandler

use of com.sun.net.httpserver.HttpHandler in project PotatOs-CMSC-355 by theneims.

the class Server method startServer.

static HttpServer startServer() throws IOException {
    final HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            server.stop(0);
        }
    }));
    HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint(new PotatOsServerApplication(), HttpHandler.class);
    server.createContext("/", handler);
    server.start();
    return server;
}
Also used : HttpHandler(com.sun.net.httpserver.HttpHandler) InetSocketAddress(java.net.InetSocketAddress) HttpServer(com.sun.net.httpserver.HttpServer)

Aggregations

HttpHandler (com.sun.net.httpserver.HttpHandler)31 InetSocketAddress (java.net.InetSocketAddress)25 HttpExchange (com.sun.net.httpserver.HttpExchange)21 IOException (java.io.IOException)17 HttpServer (com.sun.net.httpserver.HttpServer)12 OutputStream (java.io.OutputStream)12 Test (org.junit.Test)5 Headers (com.sun.net.httpserver.Headers)3 HttpContext (com.sun.net.httpserver.HttpContext)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BasicAuthenticator (com.sun.net.httpserver.BasicAuthenticator)2 InputStream (java.io.InputStream)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 UnsupportedTypeException (co.cask.cdap.api.data.schema.UnsupportedTypeException)1 CloseableIterator (co.cask.cdap.api.dataset.lib.CloseableIterator)1