Example usage for io.vertx.core.http HttpServerOptions HttpServerOptions

List of usage examples for io.vertx.core.http HttpServerOptions HttpServerOptions

Introduction

In this page you can find the example usage for io.vertx.core.http HttpServerOptions HttpServerOptions.

Prototype

public HttpServerOptions(JsonObject json) 

Source Link

Document

Create an options from JSON

Usage

From source file:io.nonobot.core.BotOptions.java

License:Apache License

public BotOptions(JsonObject json) {
    name = json.getString("name", DEFAULT_NAME);
    httpServerOptions = json.getJsonObject("httpServerOptions") != null
            ? new HttpServerOptions(json.getJsonObject("httpServerOptions"))
            : null;/*w  w  w  . ja  v a2s  . c  o m*/
}

From source file:io.nonobot.core.BotOptions.java

License:Apache License

public BotOptions(BotOptions that) {
    name = that.name;
    httpServerOptions = that.httpServerOptions != null ? new HttpServerOptions(that.httpServerOptions) : null;
}

From source file:net.sf.sgsimulator.sgsrest.SGSVertxServer.java

License:Open Source License

public static void main(String[] args) throws Exception {
    String configFile = null;//from  w  w w  .ja  v  a 2  s .co  m
    if (args.length == 0) {
        configFile = "config.json";
    } else {
        configFile = args[0];
    }

    Path configPath = Paths.get(configFile);
    JsonObject config = new JsonObject(new String(Files.readAllBytes(configPath)));

    Random r = new Random(new Date().getTime());
    char c1 = (char) (r.nextInt(26) + 'a');
    char c2 = (char) (r.nextInt(26) + 'a');
    char c3 = (char) (r.nextInt(26) + 'a');
    String admincode = "" + c1 + c2 + c3;
    System.getProperties().put("sgsimulator.admincode", admincode);

    Vertx vertx = Vertx.vertx();
    System.out.println("****************************");
    System.out.println("Starting...");
    System.out.println("To load pages:");
    System.out.println(
            "http://" + config.getString("host") + ":" + config.getInteger("port") + "/sg/pages/panel");
    System.out.println("Admin interface (only allowed from " + config.getString("adminip") + ":");
    System.out.println("http://" + config.getString("host") + ":" + config.getInteger("port")
            + "/sg/pages/admin/" + admincode);
    System.out.println("Projector screen interface (only allowed from " + config.getString("adminip") + ":");
    System.out.println(
            "http://" + config.getString("host") + ":" + config.getInteger("port") + "/sg/pages/screen");

    System.out.println("****************************");

    VertxNubes nubes = new VertxNubes(vertx, config);

    // System.err.println("IP:"+ip.substring(1));

    // config.put("host", ip.substring(1));
    System.getProperties().put("sgsimulator.scenario", config.getJsonObject("gridlab").getString("scenario"));
    System.getProperties().put("sgsimulator.adminip", config.getString("adminip"));
    nubes.bootstrap(res -> {
        if (res.succeeded()) {
            final Router router = res.result();
            final HttpServer server = vertx.createHttpServer(new HttpServerOptions(config));
            server.requestHandler(router::accept);
            server.listen();
            System.out.println("****************************");
            System.out.println("Started...");
            System.out.println("****************************");
        } else {
            res.cause().printStackTrace();
        }
    });
    // nubes.stop((_void) -> {
    // vertx.close();
    // });
}