Passing configuration to a verticle
Configuration in the form of JSON can be passed to a verticle at deployment time:
var config = {
"name" : "tim",
"directory" : "/blah"
};
var options = {
"config" : config
};
vertx.deployVerticle("MyOrderProcessorVerticle.js", options);
This configuration is then available via the Context
object.
The configuration is returned as a JavaScript object so you can retrieve data as follows:
// The context object can be retrieve either using:
console.log("Configuration: " + Vertx.currentContext().config().name);
// or:
console.log("Configuration: " + vertx.getOrCreateContext().config().name);
Note
|
The access to the context object is made either using Vertx.currentContext or using
getOrCreateContext .
|
Accessing environment variables in a Verticle
Environment variables and system properties are accessible from a verticle using the Java API:
console.log(java.lang.System.getProperty("foo"));
console.log(java.lang.System.getenv("HOME"));