Example usage for io.vertx.core DeploymentOptions toJson

List of usage examples for io.vertx.core DeploymentOptions toJson

Introduction

In this page you can find the example usage for io.vertx.core DeploymentOptions toJson.

Prototype

public JsonObject toJson() 

Source Link

Document

Convert this to JSON

Usage

From source file:io.knotx.launcher.KnotxModuleVerticleFactory.java

License:Apache License

@Override
public void resolve(String id, DeploymentOptions deploymentOptions, ClassLoader classLoader,
        Future<String> resolution) {
    String identifier = VerticleFactory.removePrefix(id);
    String descriptorFile = identifier + ".json";
    try {/*  www. j av  a  2 s  . c  o  m*/
        JsonObject descriptor = readDescriptor(classLoader, descriptorFile);
        String main = readVerticleMainClass(descriptor, descriptorFile);

        // Any options specified in the module config will override anything specified at deployment time
        // Options and Config specified in knotx starter JSON will override those configurations
        JsonObject depOptions = deploymentOptions.toJson();
        JsonObject depConfig = depOptions.getJsonObject(CONFIG_KEY, new JsonObject());

        JsonObject knotOptions = descriptor.getJsonObject(OPTIONS_KEY, new JsonObject());
        JsonObject knotConfig = knotOptions.getJsonObject(CONFIG_KEY, new JsonObject());
        depOptions.mergeIn(knotOptions);
        depOptions.put(CONFIG_KEY, JsonObjectUtil.deepMerge(knotConfig, depConfig));

        JsonObject serviceDescriptor = new JsonObject().put(OPTIONS_KEY, depOptions);

        // Any options or config provided by system properties will override anything specified
        // at deployment time and on starter Json config
        serviceDescriptor = overrideConfigWithSystemProperties(identifier, serviceDescriptor);

        deploymentOptions.fromJson(serviceDescriptor.getJsonObject(OPTIONS_KEY));
        resolution.complete(main);
    } catch (Exception e) {
        resolution.fail(e);
    }
}