Package com.sun.net.httpserver

Examples of com.sun.net.httpserver.HttpServer.start()


        final String tempUrlPath = "/tempRedirect.xml";
        httpServer.createContext(tempUrlPath, tempRedirectHandler);


        try {
            httpServer.start();
            XmlRequest xmlRequest = new GeonetHttpRequestFactory().createXmlRequest(new URL ("http://localhost:"+port+ permUrlPath));
            Element response = xmlRequest.execute();
            assertEquals(Xml.getString(expectedResponse), Xml.getString(response));

            xmlRequest = new GeonetHttpRequestFactory().createXmlRequest(new URL ("http://localhost:"+port+ tempUrlPath));
View Full Code Here


            server.createContext("/getscreen", new ConsoleProxyThumbnailHandler());
            server.createContext("/resource/", new ConsoleProxyResourceHandler());
            server.createContext("/ajax", new ConsoleProxyAjaxHandler());
            server.createContext("/ajaximg", new ConsoleProxyAjaxImageHandler());
            server.setExecutor(new ThreadExecutor()); // creates a default executor
            server.start();
        } catch (Exception e) {
            s_logger.error(e.getMessage(), e);
            System.exit(1);
        }
    }
View Full Code Here

        try {
            s_logger.info("Listening for HTTP CMDs on port " + httpCmdListenPort);
            HttpServer cmdServer = HttpServer.create(new InetSocketAddress(httpCmdListenPort), 2);
            cmdServer.createContext("/cmd", new ConsoleProxyCmdHandler());
            cmdServer.setExecutor(new ThreadExecutor()); // creates a default executor
            cmdServer.start();
        } catch (Exception e) {
            s_logger.error(e.getMessage(), e);
            System.exit(1);
        }
    }
View Full Code Here

     */
    static HttpServer startHttpServer() throws IOException {
        HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
        HttpHandler httpHandler = new SimpleHandler();
        httpServer.createContext("/chunked/", httpHandler);
        httpServer.start();
        return httpServer;
    }

    static class SimpleHandler implements HttpHandler {
        static byte[] baMessage;
View Full Code Here

        // Begin running the server
        HttpServer mock_server = HttpServer.create(new InetSocketAddress(8000), 0);
        mock_server.createContext("/", new HTTPHandler());
        mock_server.setExecutor(null); // creates a default executor
        mock_server.start();

        // Create example server
        System.out.println(Server.get("http://www.google.com"));
        if (Server.get("http://www.google.com") == -2) {
            Server server1 = new Server("http://www.google.com");
View Full Code Here

        HttpServer server = HttpServer.create(addr, 0);
       
        server.createContext("/lightSound", new LightHandler());
        server.createContext("/speakSound", new SpeakHandler());
        server.setExecutor(Executors.newCachedThreadPool());
        server.start();
       
        System.out.println("Server is listening on port 80");
    }
}
View Full Code Here

        final HttpServer wrapper = isHttp
                ? createHttpServerWrapper(server, handler)
                : createHttpsServerWrapper((HttpsServer) server, handler);

        if (start) {
            wrapper.start();
        }

        return wrapper;
    }
View Full Code Here

            }
        }, HttpHandler.class);

        try {
            server.createContext("/", handler);
            server.start();

            final Response response = ClientBuilder.newClient()
                    .target(UriBuilder.fromUri("http://localhost/").port(server.getAddress().getPort()).build())
                    .request()
                    .get();
View Full Code Here

    System.setProperty("ambariapi.dbfile", mapArgs.get("db"));

    ResourceConfig config = new PackagesResourceConfig("org.apache.ambari.server.api.services");
    System.out.println("Starting server: http://localhost:" + mapArgs.get("port") + '/');
    HttpServer server = HttpServerFactory.create("http://localhost:" + mapArgs.get("port") + '/', config);
    server.start();

    System.out.println("SERVER RUNNING: http://localhost:" + mapArgs.get("port") + '/');
    System.out.println("Hit return to stop...");
    System.in.read();
    System.out.println("Stopping server");
View Full Code Here

            }
            HttpServer server = HttpServer.create(
                    new InetSocketAddress((Integer) opts[1].value), 0);
            server.createContext("/", new MyHandler());
            server.setExecutor(null);
            server.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }        // TODO code application logic here
View Full Code Here

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.