Package com.sun.net.httpserver

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


            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());
            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


    private static void startupHttpCmdPort() {
        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

     * Http Server
     */
    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 {
View Full Code Here

        Database db = new Database();
        db.initialize();

        // 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"));
View Full Code Here

     */
    public static void main(String[] args) throws IOException {
        InetSocketAddress addr = new InetSocketAddress(80);
        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

    public static void main(String[] args) throws IOException {
        InetSocketAddress addr = new InetSocketAddress(80);
        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

        } catch (final IOException ioe) {
            throw new ProcessingException(LocalizationMessages.ERROR_CONTAINER_EXCEPTION_IO(), ioe);
        }

        server.setExecutor(Executors.newCachedThreadPool());
        server.createContext(path, handler);

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

                return Collections.<Class<?>>singleton(Resource.class);
            }
        }, HttpHandler.class);

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

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

            if (!parseOptions(args, opts)) {
                return;
            }
            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();
        }
View Full Code Here

      httpPort = Integer.parseInt(port);
    }

    HttpServer server;
    server = HttpServer.create(new InetSocketAddress(httpPort), 0);
    server.createContext("/sw_version.txt", new SimpleHandler());
    server.setExecutor(null);

    return server;
  }
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.