当前位置: 首页>>代码示例>>Java>>正文


Java EventBus.send方法代码示例

本文整理汇总了Java中org.vertx.java.core.eventbus.EventBus.send方法的典型用法代码示例。如果您正苦于以下问题:Java EventBus.send方法的具体用法?Java EventBus.send怎么用?Java EventBus.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.vertx.java.core.eventbus.EventBus的用法示例。


在下文中一共展示了EventBus.send方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gridfsReadFile

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
public static void gridfsReadFile(String id, final EventBus eb,
		final String gridfsAddress, final Handler<Buffer> handler) {
	JsonObject find = new JsonObject();
	find.putString("action", "findone");
	find.putObject("query", new JsonObject("{ \"_id\": \"" + id + "\"}"));
	byte [] header = null;
	try {
		header = find.toString().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		handler.handle(new Buffer());
	}
	if (header != null) {
		Buffer buf = new Buffer(header);
		buf.appendInt(header.length);
		eb.send(gridfsAddress, buf, new  Handler<Message>() {
		@Override
		public void handle(Message res) {
			if (res.body() instanceof Buffer) {
				handler.handle((Buffer) res.body());
			} else {
				handler.handle(null);
			}
		}
	});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:27,代码来源:FileUtils.java

示例2: gridfsCopyFile

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
public static void gridfsCopyFile(String id, EventBus eb, String gridfsAddress,
		final Handler<JsonObject> handler) {
	JsonObject find = new JsonObject();
	find.putString("action", "copy");
	find.putObject("query", new JsonObject("{ \"_id\": \"" + id + "\"}"));
	byte [] header = null;
	try {
		header = find.toString().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		handler.handle(new JsonObject().putString("status", "error"));
	}
	if (header != null) {
		Buffer buf = new Buffer(header);
		buf.appendInt(header.length);
		eb.send(gridfsAddress, buf, new  Handler<Message<JsonObject>>() {
			@Override
			public void handle(Message<JsonObject> res) {
				handler.handle(res.body());
			}
		});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:23,代码来源:FileUtils.java

示例3: call

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
public static void call(
        final EventBus eventBus,
        final String address,
        final AbstractCommand command) {

    eventBus.send(address, command.toJson());
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:8,代码来源:Commands.java

示例4: gridfsWriteBuffer

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
private static void gridfsWriteBuffer(String id, Buffer buff, Long maxSize,
	final Handler<JsonObject> handler, EventBus eb, String contentType,
	String filename, final JsonObject m, final String gridfsAddress) {
	JsonObject save = new JsonObject();
	save.putString("action", "save");
	save.putString("content-type", contentType);
	save.putString("filename", filename);
	if (id != null && !id.trim().isEmpty()) {
		save.putString("_id", id);
	}
	final JsonObject metadata = (m != null) ? m : new JsonObject()
			.putString("content-type", contentType)
			.putString("filename", filename);
	if (metadata.getLong("size", 0l).equals(0l)) {
		metadata.putNumber("size", buff.length());
	}
	if (maxSize != null && maxSize < metadata.getLong("size", 0l)) {
		handler.handle(new JsonObject().putString("status", "error")
			.putString("message", "file.too.large"));
		return;
	}
	byte [] header = null;
	try {
		header = save.toString().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		JsonObject json = new JsonObject().putString("status", "error")
				.putString("message", e.getMessage());
		handler.handle(json);
	}
	if (header != null) {
		buff.appendBytes(header).appendInt(header.length);
		eb.send(gridfsAddress, buff, new Handler<Message<JsonObject>>() {
			@Override
			public void handle(Message<JsonObject> message) {
				handler.handle(message.body()
						.putObject("metadata", metadata));
			}
		});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:41,代码来源:FileUtils.java

示例5: gridfsRemoveFiles

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
public static void gridfsRemoveFiles(JsonArray ids, EventBus eb, String gridfsAddress,
		final Handler<JsonObject> handler) {
	JsonObject find = new JsonObject();
	find.putString("action", "remove");
	JsonObject query = new JsonObject();
	if (ids != null && ids.size() == 1) {
		query.putString("_id", ids.<String>get(0));
	} else {
		query.putObject("_id", new JsonObject().putArray("$in", ids));
	}
	find.putObject("query", query);
	byte [] header = null;
	try {
		header = find.toString().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		handler.handle(new JsonObject().putString("status", "error"));
	}
	if (header != null) {
		Buffer buf = new Buffer(header);
		buf.appendInt(header.length);
		eb.send(gridfsAddress, buf, new  Handler<Message<JsonObject>>() {
			@Override
			public void handle(Message<JsonObject> res) {
				if (handler != null) {
					handler.handle(res.body());
				}
			}
		});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:31,代码来源:FileUtils.java

示例6: sendStartup

import org.vertx.java.core.eventbus.EventBus; //导入方法依赖的package包/类
public static void sendStartup(final JsonObject app, JsonArray actions, final EventBus eb, final String address, final Vertx vertx,
		final Handler<Message<JsonObject>> handler) throws IOException {
	if (actions == null || actions.size() == 0) {
		actions = loadSecuredActions(vertx);
	}
	JsonObject jo = new JsonObject();
	jo.putObject("application", app)
	.putArray("actions", actions);
	eb.send(address, jo, new Handler<Message<JsonObject>>() {
		public void handle(final Message<JsonObject> appEvent) {
			if("error".equals(appEvent.body().getString("status"))){
				log.error("Error registering application " + app.getString("name"));
				if(handler != null) handler.handle(appEvent);
				return;
			}

			final JsonArray widgetsArray = loadWidgets(app.getString("name"), vertx);
			if(widgetsArray.size() == 0){
				if(handler != null) handler.handle(appEvent);
				return;
			}

			final JsonObject widgets = new JsonObject().putArray("widgets", widgetsArray);
			eb.send(address+".widgets", widgets, new Handler<Message<JsonObject>>() {
				public void handle(Message<JsonObject> event) {
					if("error".equals(event.body().getString("status"))){
						log.error("Error registering widgets for application " + app.getString("name"));
					} else {
						log.info("Successfully registered widgets for application " + app.getString("name"));
					}
					if(handler != null) handler.handle(appEvent);
				}
			});
		}
	});
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:37,代码来源:StartupUtils.java


注:本文中的org.vertx.java.core.eventbus.EventBus.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。