本文整理匯總了Java中org.vertx.java.core.eventbus.Message.reply方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.reply方法的具體用法?Java Message.reply怎麽用?Java Message.reply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.vertx.java.core.eventbus.Message
的用法示例。
在下文中一共展示了Message.reply方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendResponse
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
public boolean sendResponse(final Message<JsonObject> msg, final String status, final int statuscode, final String message, final String severity, final Object result) {
boolean success = false;
if (msg == null) {
success = false;
}
else {
JsonObject responseMsg = new JsonObject();
responseMsg.putString(PROPERTY_MSG_STATUS, status);
if (statuscode >= 100) responseMsg.putNumber(PROPERTY_MSG_STATUSCODE, statuscode);
if (message != null) responseMsg.putString(PROPERTY_MSG_MESSAGE, message);
if (severity != null) responseMsg.putString(PROPERTY_MSG_SEVERITY, severity);
if (result != null) responseMsg.putValue(PROPERTY_MSG_RESULT, result);
msg.reply(responseMsg);
success = true;
}
return success;
}
示例2: registerMethod
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
public void registerMethod(String address, String method, boolean local)
throws NoSuchMethodException, IllegalAccessException {
final MethodHandle mh = lookup.bind(this, method,
MethodType.methodType(void.class, Message.class));
Handler<Message<JsonObject>> handler = new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> message) {
try {
mh.invokeExact(message);
} catch (Throwable e) {
container.logger().error(e.getMessage(), e);
JsonObject json = new JsonObject().putString("status", "error")
.putString("message", e.getMessage());
message.reply(json);
}
}
};
if (local) {
Server.getEventBus(vertx).registerLocalHandler(busPrefix + address, handler);
} else {
Server.getEventBus(vertx).registerHandler(busPrefix + address, handler);
}
}
示例3: busApi
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@BusAddress("communityPages")
public void busApi(Message<JsonObject> message) {
String action = message.body().getString("action", "");
final String pageId = message.body().getString("pageId");
switch (action) {
case "create" :
UserInfos user = UserUtils.sessionToUserInfos(message.body().getObject("user"));
JsonObject page = message.body().getObject("page");
crudService.create(page, user, busResponseHandler(message));
break;
case "share" :
String userId = message.body().getString("userId");
String groupId = message.body().getString("groupId");
List<String> actions = message.body().getArray("actions").toList();
shareService.groupShare(userId, groupId, pageId, actions, busResponseHandler(message));
break;
case "delete" :
crudService.delete(pageId, busResponseHandler(message));
break;
case "get" :
crudService.retrieve(pageId, busResponseHandler(message));
break;
case "update" :
crudService.update(pageId, message.body().getObject("page"), busResponseHandler(message));
break;
default:
message.reply(new JsonObject().putString("status", "error")
.putString("message", "invalid.action"));
}
}
示例4: sendStatus
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
public void sendStatus(String status, Message<JsonObject> message, JsonObject json) {
if (json == null) {
json = new JsonObject();
}
json.putString("status", status);
message.reply(json);
}
示例5: handle
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Override
public void handle(Message event) {
assertEquals(expectations.get("address"), event.address());
assertTrue(sentObject.getClass().isInstance(event.body()));
if (sentObject instanceof byte[]) {
assertArrayEquals((byte[]) sentObject, (byte[]) event.body());
} else {
assertEquals(sentObject, event.body());
}
// echo back received message
event.reply(event.body());
}
示例6: findByName
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
private void findByName(Message m) {
final Parameter<String> params = gson.fromJson(m.body().toString(), Parameter.class);
Logger logger = container.logger();
m.reply(gson.toJson(repository.findEmployeeByFirstName(params.getValue("name"))));
logger.info("reply to: " + m.body());
}
示例7: getAll
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Path("/employeeAll")
@OperationType(Type.REST_GET)
//@Produces("text/json")
public void getAll(Message m) {
Logger logger = container.logger();
m.reply(gson.toJson(repository.getAllEmployees()));
logger.info("reply to: " + m.body());
}
示例8: findByName
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Path("/employeeByName")
// @Produces("text/json")
@OperationType(Type.REST_GET)
public void findByName(@QueryParam("name") String name, @QueryParam("lastname") String lastname, Message message) {
Logger logger = container.logger();
logger.info("parameter name: " + name + " : " + lastname);
message.reply(gson.toJson(repository.findEmployeeByFirstName(name)));
logger.info("reply to: " + message.body());
}
示例9: execute
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Override
public void execute(final Message message) {
// Do nothing by default
message.reply(RESULT_OK);
}
示例10: execute
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Override
public void execute(final Message message) {
// Call verticle init method
m_activator.initVerticle();
message.reply(RESULT_OK);
}
示例11: execute
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Override
public void execute(final Message message) {
m_logger.info("Command: {}", toJson());
message.reply(resultOk());
}
示例12: sendError
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
public void sendError(Message<JsonObject> message, String error, Exception e) {
logger.error(error, e);
JsonObject json = new JsonObject().putString("status", "error").putString("message", error);
message.reply(json);
}
示例13: getServicesInfo
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
private void getServicesInfo(Message<JsonObject> message) {
final JsonArray all = new JsonArray();
handlers.keySet().forEach(handler->all.addObject(new JsonObject(handler)));
message.reply(new JsonObject().putArray("services",all));
}
示例14: info
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
private void info(Message m) {
Logger logger = container.logger();
m.reply(getServiceDescriptor());
logger.info("reply to: " + m.body());
}
示例15: getTestEmployeeOne
import org.vertx.java.core.eventbus.Message; //導入方法依賴的package包/類
@Path("/testEmployeeOne")
@OperationType(Type.REST_GET)
@Produces("application/json")
public void getTestEmployeeOne(@QueryParam("name") String name, @QueryParam("lastname") String lastname, Message message) {
message.reply(name + ":" + lastname);
}