Search in sources :

Example 31 with HttpServer

use of com.sun.net.httpserver.HttpServer in project elasticsearch by elastic.

the class RestClientMultipleHostsIntegTests method stopHttpServers.

@AfterClass
public static void stopHttpServers() throws IOException {
    restClient.close();
    restClient = null;
    for (HttpServer httpServer : httpServers) {
        httpServer.stop(0);
    }
    httpServers = null;
}
Also used : HttpServer(com.sun.net.httpserver.HttpServer) MockHttpServer(org.elasticsearch.mocksocket.MockHttpServer) AfterClass(org.junit.AfterClass)

Example 32 with HttpServer

use of com.sun.net.httpserver.HttpServer in project pinot by linkedin.

the class MultiGetRequestTest method startServer.

private HttpServer startServer(int port, HttpHandler handler) throws IOException {
    final HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
    server.createContext(URI_PATH, handler);
    new Thread(new Runnable() {

        @Override
        public void run() {
            server.start();
        }
    }).start();
    servers.add(server);
    return server;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HttpServer(com.sun.net.httpserver.HttpServer)

Example 33 with HttpServer

use of com.sun.net.httpserver.HttpServer in project pinot by linkedin.

the class ServerTableSizeReaderTest method startServer.

private HttpServer startServer(int port, HttpHandler handler) throws IOException {
    final HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
    server.createContext(URI_PATH, handler);
    new Thread(new Runnable() {

        @Override
        public void run() {
            server.start();
        }
    }).start();
    return server;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HttpServer(com.sun.net.httpserver.HttpServer)

Example 34 with HttpServer

use of com.sun.net.httpserver.HttpServer in project heron by twitter.

the class SchedulerServer method createServer.

protected HttpServer createServer(int port, Executor executor) throws IOException {
    HttpServer server = HttpServer.create(new InetSocketAddress(port), SERVER_BACK_LOG);
    server.setExecutor(executor);
    return server;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HttpServer(com.sun.net.httpserver.HttpServer)

Example 35 with HttpServer

use of com.sun.net.httpserver.HttpServer in project cloudstack by apache.

the class ConsoleProxy method startupHttpMain.

private static void startupHttpMain() {
    try {
        ConsoleProxyServerFactory factory = getHttpServerFactory();
        if (factory == null) {
            s_logger.error("Unable to load HTTP server factory");
            System.exit(1);
        }
        HttpServer server = factory.createHttpServerInstance(httpListenPort);
        server.createContext("/getscreen", new ConsoleProxyThumbnailHandler());
        server.createContext("/resource/", new ConsoleProxyResourceHandler());
        server.createContext("/ajax", new ConsoleProxyAjaxHandler());
        server.createContext("/ajaximg", new ConsoleProxyAjaxImageHandler());
        // creates a default executor
        server.setExecutor(new ThreadExecutor());
        server.start();
    } catch (Exception e) {
        s_logger.error(e.getMessage(), e);
        System.exit(1);
    }
}
Also used : HttpServer(com.sun.net.httpserver.HttpServer) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

HttpServer (com.sun.net.httpserver.HttpServer)49 InetSocketAddress (java.net.InetSocketAddress)29 HttpHandler (com.sun.net.httpserver.HttpHandler)12 IOException (java.io.IOException)10 Test (org.junit.Test)8 HttpExchange (com.sun.net.httpserver.HttpExchange)7 File (java.io.File)7 HttpContext (com.sun.net.httpserver.HttpContext)6 JarFile (java.util.jar.JarFile)6 MockHttpServer (org.elasticsearch.mocksocket.MockHttpServer)6 URL (java.net.URL)5 BasicAuthenticator (com.sun.net.httpserver.BasicAuthenticator)3 HttpsServer (com.sun.net.httpserver.HttpsServer)3 InputStream (java.io.InputStream)3 ExecutorService (java.util.concurrent.ExecutorService)3 CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)2 HttpsConfigurator (com.sun.net.httpserver.HttpsConfigurator)2 FileNotFoundException (java.io.FileNotFoundException)2 OutputStream (java.io.OutputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2