List of usage examples for io.vertx.core.json JsonObject JsonObject
public JsonObject()
From source file:examples.ConfigYamlExamples.java
License:Apache License
public void example1(Vertx vertx) { ConfigStoreOptions store = new ConfigStoreOptions().setType("file").setFormat("yaml") .setConfig(new JsonObject().put("path", "my-config.yaml")); ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store)); }
From source file:examples.ConfigZookeeperExamples.java
License:Apache License
public void example1(Vertx vertx) { ConfigStoreOptions store = new ConfigStoreOptions().setType("zookeeper") .setConfig(new JsonObject().put("connection", "localhost:2181").put("path", "/path/to/my/conf")); ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store)); }
From source file:examples.CoreExamples.java
License:Open Source License
public void example13(Vertx vertx) { JsonObject config = new JsonObject().put("name", "tim").put("directory", "/blah"); DeploymentOptions options = new DeploymentOptions().setConfig(config); vertx.deployVerticle("com.mycompany.MyOrderProcessorVerticle", options); }
From source file:examples.EventBusServiceExamples.java
License:Open Source License
public void example1(ServiceDiscovery discovery) { Record record = EventBusService.createRecord("some-eventbus-service", // The service name "address", // the service address, "examples.MyService", // the service interface as string new JsonObject().put("some-metadata", "some value")); discovery.publish(record, ar -> { // .../*from w w w . j a v a2s . co m*/ }); }
From source file:examples.EventBusServiceExamples.java
License:Open Source License
public void example2(ServiceDiscovery discovery) { // Get the record discovery.getRecord(new JsonObject().put("name", "some-eventbus-service"), ar -> { if (ar.succeeded() && ar.result() != null) { // Retrieve the service reference ServiceReference reference = discovery.getReference(ar.result()); // Retrieve the service object MyService service = reference.get(); // Dont' forget to release the service reference.release();/*from www . j a v a 2s.c o m*/ } }); }
From source file:examples.HTTPEndpointExamples.java
License:Open Source License
public void example1(ServiceDiscovery discovery) { Record record1 = HttpEndpoint.createRecord("some-http-service", // The service name "localhost", // The host 8433, // the port "/api" // the root of the service );// w w w . j a v a 2 s .c om discovery.publish(record1, ar -> { // ... }); Record record2 = HttpEndpoint.createRecord("some-other-name", // the service name true, // whether or not the service requires HTTPs "localhost", // The host 8433, // the port "/api", // the root of the service new JsonObject().put("some-metadata", "some value")); }
From source file:examples.HTTPEndpointExamples.java
License:Open Source License
public void example2(ServiceDiscovery discovery) { // Get the record discovery.getRecord(new JsonObject().put("name", "some-http-service"), ar -> { if (ar.succeeded() && ar.result() != null) { // Retrieve the service reference ServiceReference reference = discovery.getReference(ar.result()); // Retrieve the service object HttpClient client = reference.get(); // You need to path the complete path client.getNow("/api/persons", response -> { // ... // Dont' forget to release the service reference.release();/*from w w w. ja v a 2 s. c o m*/ }); } }); }
From source file:examples.HTTPEndpointExamples.java
License:Open Source License
public void example3(ServiceDiscovery discovery) { HttpEndpoint.getClient(discovery, new JsonObject().put("name", "some-http-service"), ar -> { if (ar.succeeded()) { HttpClient client = ar.result(); // You need to path the complete path client.getNow("/api/persons", response -> { // ... // Dont' forget to release the service ServiceDiscovery.releaseServiceObject(discovery, client); });/* w w w . j a v a2s . com*/ } }); }
From source file:examples.InitMongoDatastore.java
License:Open Source License
public void initMongoDatastore(Vertx vertx, String database) { Objects.requireNonNull(database, "database is required"); JsonObject config = new JsonObject(); config.put("connection_string", "mongodb://localhost:27017"); config.put("db_name", database); MongoClient mongoClient = MongoClient.createNonShared(vertx, config); MongoDataStore mongoDataStore = new MongoDataStore(vertx, mongoClient, config); }
From source file:examples.InitMySql.java
License:Open Source License
public void initMySqlClient(Vertx vertx, String username, String password, String database) { Objects.requireNonNull(username, "Username is required"); Objects.requireNonNull(password, "Password is required"); Objects.requireNonNull(database, "database is required"); JsonObject mySQLClientConfig = new JsonObject().put("host", "localhost").put("username", username) .put("password", password).put("database", database).put("port", 3306) .put(IKeyGenerator.DEFAULT_KEY_GENERATOR, DefaultKeyGenerator.NAME); mySQLClient = MySQLClient.createShared(vertx, mySQLClientConfig); datastore = new MySqlDataStore(vertx, mySQLClient, mySQLClientConfig); }