Passing configuration to a verticle
Configuration in the form of JSON can be passed to a verticle at deployment time:
JsonObject config = new JsonObject().put("name", "tim").put("directory", "/blah");
DeploymentOptions options = new DeploymentOptions().setConfig(config);
vertx.deployVerticle("com.mycompany.MyOrderProcessorVerticle", options);
This configuration is then available via the Context
object or directly using the
config
method. The configuration is returned as a JSON object so you
can retrieve data as follows:
System.out.println("Configuration: " + config().getString("name"));
Accessing environment variables in a Verticle
Environment variables and system properties are accessible using the Java API:
System.getProperty("prop");
System.getenv("HOME");