Search in sources :

Example 6 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class Http2Settings method toJson.

public JsonObject toJson() {
    JsonObject json = new JsonObject();
    Http2SettingsConverter.toJson(this, json);
    return json;
}
Also used : JsonObject(io.vertx.core.json.JsonObject)

Example 7 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class HttpClientOptions method toJson.

/**
   * Convert to JSON
   *
   * @return the JSON
   */
public JsonObject toJson() {
    JsonObject json = super.toJson();
    HttpClientOptionsConverter.toJson(this, json);
    return json;
}
Also used : JsonObject(io.vertx.core.json.JsonObject)

Example 8 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class HttpServerOptions method toJson.

/**
   * Convert to JSON
   *
   * @return the JSON
   */
public JsonObject toJson() {
    JsonObject json = super.toJson();
    HttpServerOptionsConverter.toJson(this, json);
    return json;
}
Also used : JsonObject(io.vertx.core.json.JsonObject)

Example 9 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class Starter method runVerticle.

private void runVerticle(String main, Args args) {
    boolean ha = args.map.get("-ha") != null;
    boolean clustered = args.map.get("-cluster") != null || ha;
    Vertx vertx = startVertx(clustered, ha, args);
    if (vertx == null) {
        // Throwable should have been logged at this point
        return;
    }
    String sinstances = args.map.get("-instances");
    int instances;
    if (sinstances != null) {
        try {
            instances = Integer.parseInt(sinstances);
            if (instances != -1 && instances < 1) {
                log.error("Invalid number of instances");
                displaySyntax();
                return;
            }
        } catch (NumberFormatException e) {
            displaySyntax();
            return;
        }
    } else {
        instances = 1;
    }
    String confArg = args.map.get("-conf");
    JsonObject conf;
    if (confArg != null) {
        try (Scanner scanner = new Scanner(new File(confArg)).useDelimiter("\\A")) {
            String sconf = scanner.next();
            try {
                conf = new JsonObject(sconf);
            } catch (DecodeException e) {
                log.error("Configuration file " + sconf + " does not contain a valid JSON object");
                return;
            }
        } catch (FileNotFoundException e) {
            try {
                conf = new JsonObject(confArg);
            } catch (DecodeException e2) {
                log.error("-conf option does not point to a file and is not valid JSON: " + confArg);
                return;
            }
        }
    } else {
        conf = null;
    }
    boolean worker = args.map.get("-worker") != null;
    String message = (worker) ? "deploying worker verticle" : "deploying verticle";
    deploymentOptions = new DeploymentOptions();
    configureFromSystemProperties(deploymentOptions, DEPLOYMENT_OPTIONS_PROP_PREFIX);
    deploymentOptions.setConfig(conf).setWorker(worker).setHa(ha).setInstances(instances);
    beforeDeployingVerticle(deploymentOptions);
    vertx.deployVerticle(main, deploymentOptions, createLoggingHandler(message, res -> {
        if (res.failed()) {
            handleDeployFailed();
        }
    }));
}
Also used : Manifest(java.util.jar.Manifest) java.util(java.util) DecodeException(io.vertx.core.json.DecodeException) VertxMetricsFactory(io.vertx.core.spi.VertxMetricsFactory) IOException(java.io.IOException) AtomicReference(java.util.concurrent.atomic.AtomicReference) Attributes(java.util.jar.Attributes) LoggerFactory(io.vertx.core.logging.LoggerFactory) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Args(io.vertx.core.impl.Args) java.net(java.net) MetricsOptions(io.vertx.core.metrics.MetricsOptions) JsonObject(io.vertx.core.json.JsonObject) Logger(io.vertx.core.logging.Logger) Method(java.lang.reflect.Method) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) JsonObject(io.vertx.core.json.JsonObject) File(java.io.File) DecodeException(io.vertx.core.json.DecodeException)

Example 10 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class AddressResolverOptions method toJson.

public JsonObject toJson() {
    JsonObject json = new JsonObject();
    AddressResolverOptionsConverter.toJson(this, json);
    return json;
}
Also used : JsonObject(io.vertx.core.json.JsonObject)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)185 Test (org.junit.Test)136 JsonArray (io.vertx.core.json.JsonArray)44 ArrayList (java.util.ArrayList)11 DeploymentOptions (io.vertx.core.DeploymentOptions)8 HashMap (java.util.HashMap)8 Launcher (io.vertx.core.Launcher)7 Buffer (io.vertx.core.buffer.Buffer)7 IOException (java.io.IOException)7 Instant (java.time.Instant)7 AsciiString (io.netty.util.AsciiString)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Message (io.vertx.core.eventbus.Message)4 File (java.io.File)4 Random (java.util.Random)4 AbstractVerticle (io.vertx.core.AbstractVerticle)3 Vertx (io.vertx.core.Vertx)3 VertxOptions (io.vertx.core.VertxOptions)3 VertxInternal (io.vertx.core.impl.VertxInternal)3 DecodeException (io.vertx.core.json.DecodeException)3