Package org.vertx.java.core.json

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


      @Override
      public void handle(AsyncResult<Collection<String>> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else if (result.result() == null) {
          message.reply(new JsonObject().putString("status", "ok").putArray("result", new JsonArray()));
        } else {
          message.reply(new JsonObject().putString("status", "ok").putArray("result", new JsonArray(result.result().toArray(new String[result.result().size()]))));
        }
      }
    });
  }
View Full Code Here


                    .putString("main", TestFeeder.class.getName()))
                .putObject("worker", new JsonObject()
                    .putString("type", "verticle")
                    .putString("main", TestWorker.class.getName())
                    .putNumber("instances", 2)))
            .putArray("connections", new JsonArray().add(new JsonObject()
                .putObject("source", new JsonObject()
                    .putString("component", "feeder")
                    .putString("port", "out"))
                .putObject("target", new JsonObject()
                    .putString("component", "worker")
View Full Code Here

        if (req.path().equals("/")) req.response().sendFile("eventbusbridge/index.html"); // Serve the index.html
        if (req.path().endsWith("vertxbus.js")) req.response().sendFile("eventbusbridge/vertxbus.js"); // Serve the js
      }
    });

    JsonArray permitted = new JsonArray();
    permitted.add(new JsonObject()); // Let everything through

    ServerHook hook = new ServerHook(logger);

    SockJSServer sockJSServer = vertx.createSockJSServer(server);
    sockJSServer.setHook(hook);
View Full Code Here

        if (req.path().equals("/")) req.response().sendFile("ebb_memleak_test/index.html"); // Serve the index.html
        if (req.path().endsWith("vertxbus.js")) req.response().sendFile("ebb_memleak_test/vertxbus.js"); // Serve the js
      }
    });

    JsonArray permitted = new JsonArray();
    permitted.add(new JsonObject()); // Let everything through

    ServerHook hook = new ServerHook(logger);

    SockJSServer sockJSServer = vertx.createSockJSServer(server);
    sockJSServer.setHook(hook);
View Full Code Here

    // HTTP server
    HttpServer httpServer = vertx.createHttpServer();
    httpServer.requestHandler(routeMatcher);

    // SockJS server
    JsonArray permitted = new JsonArray();
    permitted.add(new JsonObject()); // Let everything through
    SockJSServer sockJSServer = vertx.createSockJSServer(httpServer);
    sockJSServer.bridge(new JsonObject().putString("prefix", "/bitcoin"), permitted, permitted);

    httpServer.listen(7777);
  }
View Full Code Here

    // HTTP server
    HttpServer httpServer = vertx.createHttpServer();
    httpServer.requestHandler(routeMatcher);

    // SockJS server
    JsonArray permitted = new JsonArray();
      permitted.add(new JsonObject()); // Let everything through
      SockJSServer sockJSServer = vertx.createSockJSServer(httpServer);
      sockJSServer.bridge(new JsonObject().putString("prefix", "/bitcoin"), permitted, permitted);

    httpServer.listen(8080);
  }
View Full Code Here

    }

    boolean bridge = getOptionalBooleanConfig("bridge", false);
    if (bridge) {
      SockJSServer sjsServer = vertx.createSockJSServer(server);
      JsonArray inboundPermitted = getOptionalArrayConfig("inbound_permitted", new JsonArray());
      JsonArray outboundPermitted = getOptionalArrayConfig("outbound_permitted", new JsonArray());

      sjsServer.bridge(getOptionalObjectConfig("sjs_config", new JsonObject().putString("prefix", "/eventbus")),
                       inboundPermitted, outboundPermitted,
                       getOptionalLongConfig("auth_timeout", 5 * 60 * 1000),
                       getOptionalStringConfig("auth_address", "vertx.basicauthmanager.authorise"));
View Full Code Here

        if (req.path.equals("/")) req.response.sendFile("eventbusbridge/index.html"); // Serve the index.html
        if (req.path.endsWith("vertxbus.js")) req.response.sendFile("eventbusbridge/vertxbus.js"); // Serve the js
      }
    });

    JsonArray permitted = new JsonArray();
    permitted.add(new JsonObject()); // Let everything through
    SockJSServer sockJSServer = vertx.createSockJSServer(server);
    sockJSServer.bridge(new JsonObject().putString("prefix", "/eventbus"), permitted, permitted);

    server.listen(8080);
  }
View Full Code Here

    // Configure the event bus bridge.
    boolean bridge = getOptionalBooleanConfig("bridge", false);
    if (bridge) {
      SockJSServer sjsServer = vertx.createSockJSServer(server);
      JsonArray inboundPermitted = getOptionalArrayConfig("in_permitted", new JsonArray());
      JsonArray outboundPermitted = getOptionalArrayConfig("out_permitted", new JsonArray());

      sjsServer.bridge(
          getOptionalObjectConfig("sjs_config", new JsonObject().putString("prefix", "/eventbus")),
          inboundPermitted, outboundPermitted, getOptionalLongConfig("auth_timeout", 5 * 60 * 1000),
          getOptionalStringConfig("auth_address", "participants.authorise"));
View Full Code Here

      // TODO: post-process deletes so that child deletes are subsumed by parent deletes.
    }

    // Notify the edit session verticle of the changes.
    JsonObject message = new JsonObject();
    JsonArray messageDelete = new JsonArray();
    JsonArray messageModify = new JsonArray();
    message.putArray("delete", messageDelete);
    message.putArray("modify", messageModify);

    // Broadcast a tree mutation to all clients.
    WorkspaceTreeUpdateBroadcastImpl broadcast = WorkspaceTreeUpdateBroadcastImpl.make();

    for (NodeInfoExt node : adds) {
      System.out.println("add: " + pathString(node));
      // Edit session doesn't care.
      // Broadcast to clients.
      MutationImpl mutation =
          MutationImpl.make().setMutationType(Mutation.Type.ADD).setNewPath(pathString(node));
      /*
       * Do not strip the node; in the case of a newly scanned directory (e.g. recursive copy), its
       * children to not get their own mutations, it's just a single tree.
       */
      mutation.setNewNodeInfo((TreeNodeInfoImpl) node);
      broadcast.getMutations().add(mutation);
    }
    for (NodeInfoExt node : removes) {
      System.out.println("del: " + pathString(node));
      // Edit session wants deletes.
      messageDelete.addString(node.getFileEditSessionKey());
      // Broadcast to clients.
      MutationImpl mutation =
          MutationImpl.make().setMutationType(Mutation.Type.DELETE).setOldPath(pathString(node));
      broadcast.getMutations().add(mutation);
    }
    for (ExpectedMove move : completedMoves) {
      System.out.println("mov: " + pathString(move.oldNode) + " to: " + pathString(move.newNode));
      // Edit session doesn't care.
      // Broadcast to clients.
      MutationImpl mutation = MutationImpl.make()
          .setMutationType(Mutation.Type.MOVE).setNewPath(pathString(move.newNode))
          .setOldPath(pathString(move.oldNode));
      // Strip the node; the client should already have the children.
      mutation.setNewNodeInfo(stripChildren(move.newNode));
      broadcast.getMutations().add(mutation);
    }
    for (NodeInfoExt node : modifies) {
      System.out.println("mod: " + pathString(node));
      // Edit session wants modifies.
      messageModify.addString(node.getFileEditSessionKey());
      // No broadcast, edit session will handle.
    }
    vertx.eventBus().send("documents.fileSystemEvents", message);
    if (treeDirty) {
      broadcast.setNewTreeVersion(Long.toString(treeVersion));
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.