Package com.sun.net.httpserver

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


        server.createContext("/SOAP", new GenericHandler("simple_soap.xml"));
        server.createContext("/JSON", new GenericHandler("public_timeline.json"));
        server.createContext("/XML", new GenericHandler("public_timeline.xml"));

        server.createContext("/TEXT", new TEXTHandler());
        server.createContext("/TEXT2", new TEXTHandler());

        server.start();

        System.out.println("Server started on IP: " + address + ":" + port + " at " + df.format(new Date()));
        String serverUri = "http://" + address + ":" + port;
View Full Code Here


        final HttpServer server = (scheme.equalsIgnoreCase("http")) ?
            HttpServer.create(new InetSocketAddress(port), 0) :
            HttpsServer.create(new InetSocketAddress(port), 0);

        server.setExecutor(Executors.newCachedThreadPool());
        server.createContext(path, handler);       
        return server;
    }
}
View Full Code Here

    out.setUrlBase("http://" + host + ":" + port);
    out.setUrlPath(path);
    out.initialize(connector, client);

    HttpServer server = HttpServer.create(new InetSocketAddress(host, port), 0);
    server.createContext(path, handler);
    return server;
  }

  static class SleepyHandler implements HttpHandler {
    private final int sleepSeconds;
View Full Code Here

        // we'll have to split the backend thread from the http server thread.
        AffinityExecutor.ServiceAffinityExecutor executor = new AffinityExecutor.ServiceAffinityExecutor("server");
        server.setExecutor(executor);
        LighthouseBackend backend = new LighthouseBackend(SERVER, kit.peerGroup(), kit.chain(), (PledgingWallet) kit.wallet(), executor);
        backend.setMinPeersForUTXOQuery(minPeersSupportingGetUTXO);
        server.createContext(LHUtils.HTTP_PATH_PREFIX, new ProjectHandler(backend));
        server.createContext("/", exchange -> {
            log.warn("404 Not Found: {}", exchange.getRequestURI());
            exchange.sendResponseHeaders(404, -1);
        });
        server.start();
View Full Code Here

        AffinityExecutor.ServiceAffinityExecutor executor = new AffinityExecutor.ServiceAffinityExecutor("server");
        server.setExecutor(executor);
        LighthouseBackend backend = new LighthouseBackend(SERVER, kit.peerGroup(), kit.chain(), (PledgingWallet) kit.wallet(), executor);
        backend.setMinPeersForUTXOQuery(minPeersSupportingGetUTXO);
        server.createContext(LHUtils.HTTP_PATH_PREFIX, new ProjectHandler(backend));
        server.createContext("/", exchange -> {
            log.warn("404 Not Found: {}", exchange.getRequestURI());
            exchange.sendResponseHeaders(404, -1);
        });
        server.start();
    }
View Full Code Here

                    // Creates server with default socket backlog
                    server = HttpServer.create(inetAddress, 0);
                    server.setExecutor(Executors.newCachedThreadPool());
                    String path = url.toURI().getPath();
                    logger.fine("Creating HTTP Context at = "+path);
                    HttpContext context = server.createContext(path);
                    server.start();

                    // we have to get actual inetAddress from server, which can differ from the original in some cases.
                    // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
                    // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
View Full Code Here

              logger.fine(err);
              throw new IllegalArgumentException(err)
            }
           
            logger.fine("Creating HTTP Context at = "+url.getPath());
            HttpContext context = server.createContext(url.getPath());
            state.oneMoreContext(url.getPath());
            return context;
        } catch(Exception e) {
            throw new ServerRtException("server.rt.err",e );
        }
View Full Code Here

            final HttpServer server = HttpServer.create(new InetSocketAddress(port), 5);
            final ExecutorService threads  = Executors.newFixedThreadPool(2);
            server.setExecutor(threads);
            server.start();

            HttpContext context = server.createContext("/stop");
            context.setHandler(new HttpHandler() {
                public void handle(HttpExchange msg) throws IOException {
                    System.out.println("Shutting down the Endpoint");
                    endpoint.stop();
                    System.out.println("Endpoint is down");
View Full Code Here

        final HttpServer server = HttpServer.create(new InetSocketAddress(port), 5);
        final ExecutorService threads  = Executors.newFixedThreadPool(2);
        server.setExecutor(threads);
        server.start();

        HttpContext context = server.createContext("/stop");
        context.setHandler(new HttpHandler() {
        public void handle(HttpExchange msg) throws IOException {
        System.out.println("Shutting down the Endpoint");
        endpoint.stop();
        System.out.println("Endpoint is down");
View Full Code Here

            final HttpServer server = HttpServer.create(new InetSocketAddress(port), 5);
            final ExecutorService threads  = Executors.newFixedThreadPool(2);
            server.setExecutor(threads);
            server.start();

            HttpContext context = server.createContext("/stop");
            context.setHandler(new HttpHandler() {
                public void handle(HttpExchange msg) throws IOException {
                    System.out.println("Shutting down the Endpoint");
                    endpoint.stop();
                    System.out.println("Endpoint is down");
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.