Package org.vertx.java.core.json

Examples of org.vertx.java.core.json.JsonObject


  private void handleDbMongo(final HttpServerRequest req) {
    findRandom(ThreadLocalRandom.current(), new Handler<Message<JsonObject>>() {
      @Override
      public void handle(Message<JsonObject> reply) {
        JsonObject world = getResultFromReply(reply);
        String result = world.encode();
        sendResponse(req, result);
      }
    });
  }
View Full Code Here


      }
    });
  }

  private JsonObject getResultFromReply(Message<JsonObject> reply) {
    JsonObject body = reply.body();
    JsonObject world = body.getObject("result");
    Object id = world.removeField("_id");
    world.putValue("id", id);
    return world;
  }
View Full Code Here

  }

  private void findRandom(Random random, Handler<Message<JsonObject>> handler) {
    vertx.eventBus().send(
        "hello.persistor",
        new JsonObject()
            .putString("action", "findone")
            .putString("collection", "World")
            .putObject("matcher", new JsonObject().putNumber("_id", (random.nextInt(10000) + 1))),
        handler);
  }
View Full Code Here

      worlds = new JsonArray();
    }

    @Override
    public void handle(Message<JsonObject> reply) {
      JsonObject world = getResultFromReply(reply);
      worlds.add(world);
      if (worlds.size() == this.queries) {
        // All queries have completed; send the response.
        String result = worlds.encode();
        sendResponse(req, result);
View Full Code Here

    this.eventBus = component.vertx().eventBus();
    this.context = component.context();
    if (this.address == null) {
      this.address = component.context().component().address();
    }
    eventBus.publish(address, new JsonObject().putString("event", "start").putObject("context", Contexts.serialize(context)));
  }
View Full Code Here

    eventBus.publish(address, new JsonObject().putString("event", "start").putObject("context", Contexts.serialize(context)));
  }

  @Override
  public void handleSend(Object message) {
    eventBus.publish(address, new JsonObject().putString("event", "send").putValue("message", message));
  }
View Full Code Here

    eventBus.publish(address, new JsonObject().putString("event", "send").putValue("message", message));
  }

  @Override
  public void handleReceive(Object message) {
    eventBus.publish(address, new JsonObject().putString("event", "receive").putValue("message", message));
  }
View Full Code Here

    eventBus.publish(address, new JsonObject().putString("event", "receive").putValue("message", message));
  }

  @Override
  public void handleStop(Component subject) {
    eventBus.publish(address, new JsonObject().putString("event", "stop").putObject("context", Contexts.serialize(context)));
  }
View Full Code Here

    eventBus = component.vertx().eventBus();
  }

  @Override
  public void handleReceive(Object message) {
    eventBus.send(address, new JsonObject()
      .putString("action", "mark")
      .putString("name", String.format("%s.receive", context.address())));
  }
View Full Code Here

      .putString("name", String.format("%s.receive", context.address())));
  }

  @Override
  public void handleSend(Object message) {
    eventBus.send(address, new JsonObject()
      .putString("action", "mark")
      .putString("name", String.format("%s.send", context.address())));
  }
View Full Code Here

TOP

Related Classes of org.vertx.java.core.json.JsonObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.