Package org.vertx.java.core.json

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


  public void emit(String event, JsonObject jsonObject) {
    JsonObject packet = new JsonObject();
    packet.putString("type", "event");
    packet.putString("name", event);

    JsonArray args = new JsonArray();
    args.addObject(jsonObject);
    packet.putArray("args", args);
    packet(packet);
  }
View Full Code Here


   */
  public void emit(String event, String data) {
    JsonObject packet = new JsonObject();
    packet.putString("type", "event");
    packet.putString("name", event);
    packet.putArray("args", new JsonArray().addString(data));
    packet(packet);
  }
View Full Code Here

        // check if the emitted event is not blacklisted
        if (manager.getSettings().getBlacklist().indexOf(packet.getString("name")) != -1) {
          log.debug("ignoring blacklisted event \'" + packet.getString("name") + "\'");
        } else {
          JsonObject params = new JsonObject();
          JsonArray args = packet.getArray("args");
          if(args != null)
            params.putArray("args", args);
          params.putString("name", packet.getString("name"));
          if (isDataAck) {
            params.putString("ack", packet.getString("ack"));
View Full Code Here

        JsonObject body = message.body();

        // Get indices to be searched
        String index = body.getString(CONST_INDEX);
        JsonArray indices = body.getArray(CONST_INDICES);
        List<String> list = new ArrayList<>();
        if (index != null) {
            list.add(index);
        }
        if (indices != null) {
            for (int i = 0; i < indices.size(); i++) {
                list.add(indices.<String>get(i));
            }
        }

        SearchRequestBuilder builder = client.prepareSearch(list.toArray(new String[list.size()]));

        // Get types to be searched
        String type = body.getString(CONST_TYPE);
        JsonArray types = body.getArray("_types");
        list.clear();
        if (type != null) {
            list.add(type);
        }
        if (types != null) {
            for (int i = 0; i < types.size(); i++) {
                list.add(types.<String>get(i));
            }
        }
        if (!list.isEmpty()) {
            builder.setTypes(list.toArray(new String[list.size()]));
        }

        // Set the query
        JsonObject query = body.getObject("query");
        if (query != null) {
            builder.setQuery(query.encode());
        }

        // Set the filter
        JsonObject filter = body.getObject("filter");
        if (filter != null) {
            builder.setPostFilter(filter.encode());
        }

        // Set facets
        JsonObject facets = body.getObject("facets");
        if (facets != null) {
            builder.setFacets(facets.encode().getBytes(CHARSET_UTF8));
        }

        // Set search type
        String searchType = body.getString("search_type");
        if (searchType != null) {
            builder.setSearchType(searchType);
        }

        // Set scroll keep alive time
        String scroll = body.getString("scroll");
        if (scroll != null) {
            builder.setScroll(scroll);
        }

        // Set Size
        Integer size = body.getInteger("size");
        if (size != null) {
            builder.setSize(size);
        }

        //Set requested fields
        JsonArray fields = body.getArray("fields");
        if (fields != null) {
            for (int i = 0; i < fields.size(); i++) {
                builder.addField(fields.<String>get(i));
            }
        }

        //Set query timeout
        Long queryTimeout = body.getLong("timeout");
View Full Code Here

        dbName = config.getString("db_name", "default_db");
        username = config.getString("username", null);
        password = config.getString("password", null);
        int poolSize = config.getInteger("pool_size", 10);

        JsonArray seedsProperty = config.getArray("seeds");

        try {
            MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
            builder.connectionsPerHost(poolSize);
            if (seedsProperty == null) {
View Full Code Here

        JsonObject json = new JsonObject();

        // Add seeds
        List<String> seeds = configurator.getSeeds();
        JsonArray arr = new JsonArray();
        json.putArray("seeds", arr);
        if (seeds != null) {
            for (String seed : seeds) {
                arr.addString(seed);
            }
        }

        Policies policies = configuration.getPolicies();
        JsonObject policiesJson = new JsonObject();
View Full Code Here

    }

    protected void initSeeds(JsonObject config) {

        // Get array of IPs, default to localhost
        JsonArray seeds = config.getArray(CONFIG_SEEDS);
        if (seeds == null || seeds.size() == 0) {
            seeds = new JsonArray().addString("127.0.0.1");
        }

        this.seeds = new ArrayList<>();
        for (int i = 0; i < seeds.size(); i++) {
            this.seeds.add(seeds.<String>get(i));
        }
    }
View Full Code Here

        JsonObject json = new JsonObject();

        // Add seeds
        List<String> seeds = configurator.getSeeds();
        JsonArray arr = new JsonArray();
        json.putArray("seeds", arr);
        if (seeds != null) {
            for (String seed : seeds) {
                arr.addString(seed);
            }
        }

        Policies policies = configuration.getPolicies();
        JsonObject policiesJson = new JsonObject();
View Full Code Here

    }

    protected void initSeeds(JsonObject config) {

        // Get array of IPs, default to localhost
        JsonArray seeds = config.getArray(CONFIG_SEEDS);
        if (seeds == null || seeds.size() == 0) {
            seeds = new JsonArray().addString("127.0.0.1");
        }

        this.seeds = new ArrayList<>();
        for (int i = 0; i < seeds.size(); i++) {
            this.seeds.add(seeds.<String>get(i));
        }
    }
View Full Code Here

   
    private JsonObject newSession() {
      String id = UUID.randomUUID().toString();
      return new JsonObject().
          putString("id", id).
          putArray("bindings", new JsonArray().addString("broadcast").addString("connection."+id));
    }
View Full Code Here

TOP

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

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.