當前位置: 首頁>>代碼示例>>Java>>正文


Java Message類代碼示例

本文整理匯總了Java中org.vertx.java.core.eventbus.Message的典型用法代碼示例。如果您正苦於以下問題:Java Message類的具體用法?Java Message怎麽用?Java Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Message類屬於org.vertx.java.core.eventbus包,在下文中一共展示了Message類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateDownloadLogs

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Override
public void updateDownloadLogs(final String id, final UserInfos user, final Handler<JsonObject> handler) {
	final QueryBuilder query = QueryBuilder.start("_id").is(id);

	final JsonObject logElem = new JsonObject().putString("userDisplayName", user.getUsername()).putObject("downloadDate", MongoDb.now());
	final MongoUpdateBuilder modifier = new MongoUpdateBuilder();
	modifier.addToSet("downloadLogs", logElem);
	mongo.update(ShareBigFiles.SHARE_BIG_FILE_COLLECTION, MongoQueryBuilder.build(query),
			modifier.build(), new Handler<Message<JsonObject>>() {
				@Override
				public void handle(Message<JsonObject> event) {
					if ("ok".equals(event.body().getString("status"))) {
						handler.handle(new JsonObject().putString("status", "ok"));
					} else {
						handler.handle(new JsonObject().putString("status", "error")
								.putString("message", event.body().getString("message")));
					}
				}
			});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:21,代碼來源:ShareBigFilesServiceImpl.java

示例2: getInfo

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Override
public void getInfo(final String fileId, final AsyncResultHandler<FileInfos> handler) {
	final JsonObject query = new JsonObject().putString(mapping.getString("file", "file"), fileId);
	mongo.findOne(collection, query, keys, new Handler<Message<JsonObject>>() {
		@Override
		public void handle(Message<JsonObject> event) {
			if ("ok".equals(event.body().getString("status"))) {
				JsonObject res = event.body().getObject("result");
				if (res != null) {
					final FileInfos fi = new FileInfos();
					fi.setApplication(application);
					fi.setId(fileId);
					fi.setName(res.getString(mapping.getString("title", "title")));
					fi.setOwner(res.getObject("owner", new JsonObject()).getString("userId"));
					handler.handle(new DefaultAsyncResult<>(fi));
				} else {
					handler.handle(new DefaultAsyncResult<>((FileInfos) null));
				}
			} else {
				handler.handle(new DefaultAsyncResult<FileInfos>(
						new StorageException(event.body().getString("message"))));
			}
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:26,代碼來源:ShareBigFileStorage.java

示例3: createPageMarkups

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
private void createPageMarkups(String pageId) {
	JsonObject updatePage = new JsonObject()
	.putString("action", "update")
	.putString("pageId", pageId)
	.putObject("page", new JsonObject()
		.putObject("markups", new JsonObject()
			.putArray("view", new JsonArray()
				.addObject(new JsonObject()
					.putString("label", "community.edit")
					.putString("resourceRight", "share")
					.putString("href", "/community#/edit/" + pageId))
				.addObject(new JsonObject()
					.putString("label", "community.back.to")
					.putString("resourceRight", "read")
					.putString("href", "/community#/list")))));
	eb.send("communityPages", updatePage, new Handler<Message<JsonObject>>() {
		@Override
		public void handle(Message<JsonObject> message) {
			if (!"ok".equals(message.body().getString("status"))) {
				log.error(message.body().getString("message"));
			}
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:community,代碼行數:25,代碼來源:CommunityController.java

示例4: deployDispatcher

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
private void deployDispatcher(
        final NotifierConfig config,
        final Handler<Message<JsonObject>> handler) {

    logger().info("Deploying dispatcher");

    JsonObject dispatcherConfig = new JsonObject();

    // Dispatcher local address
    dispatcherConfig.putString(CONF_KEY_LOCAL_ADDRESS, DISPATCHER_LOCAL_ADDRESS);

    Commands.call(
            eventBus(),
            localAddress(),
            Commands.cmdDeployVerticle(
                    Dispatcher.class.getName(),
                    dispatcherConfig,
                    1,
                    false,
                    true), // Dispatcher is a worker
            handler);
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:23,代碼來源:Activator.java

示例5: undeployFilter

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
private void undeployFilter(
        final FilterDef filter,
        final Handler<Message<JsonObject>> handler) {

    String address = filter.getModule(); // Address of filter activator
    String verticle = filter.getVerticle();
    String deploymentId = filter.getDeploymentId();

    logger().info("Undeploying {} (activator: {} deploymentId: {})",
            verticle,
            address,
            deploymentId);

    Commands.call(
            eventBus(),
            address,
            Commands.cmdUndeployVerticle(deploymentId),
            handler);
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:20,代碼來源:Activator.java

示例6: registerHandler

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
/**
 * Override this to customize the registration of the message handler. The
 * default implementation registers a JVM local handler.
 */
protected void registerHandler() {

    String srcAddr = getSourceAddress();
    eventBus().registerLocalHandler(srcAddr, new Handler<Message<JsonObject>>() {

        @Override
        public void handle(final Message<JsonObject> event) {
            // Never fall outside of the event handler
            try {
                handleEvent(event.body());
            } catch (Exception e) {
                logger().error("Failed to handle event: {}", event.body(), e);
            }
        }

    });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:22,代碼來源:AbstractFilter.java

示例7: execute

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Override
public void execute(final Message message) {
    // Call verticle undeploy method
    JsonArray args = getArgs();
    final String verticle = (String) args.get(0);

    m_executor.undeployVerticle(
            verticle,
            new Handler<AsyncResult<Void>>() {

                @Override
                public void handle(AsyncResult<Void> ar) {
                    if (ar.failed()) {
                        m_logger.error("Failed to undeploy verticle: {}",
                                verticle, ar.cause());
                        message.reply(Commands.result(
                                        ERR_UNDEPLOY_FAILED,
                                        REASON_UNDEPLOY_FAILED + ar.cause()));
                    } else {
                        message.reply(RESULT_OK);
                    }
                }
            }
    );
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:26,代碼來源:AbstractActivator.java

示例8: initVerticle

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Override
protected void initVerticle() {
    Commands.call(
            eventBus(),
            LOCAL_ADDRESS,
            Commands.cmdDeployVerticle(
                    TestVerticle1.class.getName(),
                    new JsonObject(),
                    1,
                    false,
                    false),
            new Handler<Message<JsonObject>>() {

                @Override
                public void handle(Message<JsonObject> message) {
                    Result result = new Result(message.body());
                    if (result.getReturnCode() != RET_DEPLOYMENT_ID) {
                        throw new IllegalStateException(result.getReason());
                    } else {
                        undeployVerticle(result.getReason()); // Deployment ID is in reason
                    }
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:25,代碼來源:ActivatorTest.java

示例9: undeployVerticle

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
private void undeployVerticle(final String deploymentId) {
    Commands.call(
            eventBus(),
            LOCAL_ADDRESS,
            Commands.cmdUndeployVerticle(deploymentId),
            new Handler<Message<JsonObject>>() {

                @Override
                public void handle(Message<JsonObject> message) {
                    Result result = new Result(message.body());
                    if (!result.isOk()) {
                        throw new IllegalStateException(result.getReason());
                    }
                    // Stop test
                    VertxAssert.testComplete();
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:19,代碼來源:ActivatorTest.java

示例10: test05TruncateCollection

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Test
public void test05TruncateCollection() {
    System.out.println("*** test05TruncateCollection ***");
    JsonObject requestObject = new JsonObject();
    requestObject.putString(ArangoPersistor.MSG_PROPERTY_TYPE, ArangoPersistor.MSG_TYPE_COLLECTION);
    requestObject.putString(CollectionAPI.MSG_PROPERTY_ACTION, CollectionAPI.MSG_ACTION_TRUNCATE);
    requestObject.putString(CollectionAPI.MSG_PROPERTY_COLLECTION, vertexColName);
    vertx.eventBus().send(address, requestObject, new Handler<Message<JsonObject>>() {
        @Override
        public void handle(Message<JsonObject> reply) {
            try {
                JsonObject response = reply.body();
                System.out.println("response: " + response);
                JsonObject arangoResult = response.getObject("result");
                VertxAssert.assertEquals("Truncation of the specified collection resulted in an error: " + response.getString("message"), "ok", response.getString("status"));
                System.out.println("response details: " + arangoResult);
            }
            catch (Exception e) {
                VertxAssert.fail("test05TruncateCollection");
            }
            VertxAssert.testComplete();
        }
    });
}
 
開發者ID:santo74,項目名稱:vertx-arangodb,代碼行數:25,代碼來源:CollectionIntegrationTest.java

示例11: testSendSms

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Test
    public void testSendSms() {
        JsonObject object = new JsonObject();
        addOptionalConfig(object);

//        object.putBinary("textBytes", CharsetUtil.encode("This is a vert.x-smpp test message. \u20AC", CharsetUtil.CHARSET_GSM));
        object.putString("textString", "This is a vert.x-smpp test message. \u20AC"); // one of the two is mandatory, bytes or string
        object.putString("source", "TEST"); // mandatory
        object.putString("destination", System.getProperty("destination", "301234567890")); // mandatory

        getVertx().eventBus().send(ADDRESS, object, new Handler<Message<JsonObject>>() {
            @Override
            public void handle(Message<JsonObject> message) {
                getContainer().logger().info(message.body());
                assertEquals("ok", message.body().getString("status"));
                testComplete();
            }
        });
    }
 
開發者ID:ialexandrakis,項目名稱:vertx-mod-smpp-client,代碼行數:20,代碼來源:ModuleSetupTest.java

示例12: doGet

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
private void doGet(Message<JsonObject> msg, int timeout, JsonObject headers, String dbName) {
    // Check required params
    
    // the path for the request
    String path = helper.getMandatoryString(msg.body(), MSG_PROPERTY_PATH, msg);
    if (path == null) return;
            
    // prepare PATH
    StringBuilder apiPath = new StringBuilder();
    if (dbName != null) apiPath.append("/_db/").append(dbName);
    apiPath.append(API_BASE_PATH);
    if (!path.startsWith("/")) apiPath.append("/");
    apiPath.append(path);
    
    httpGet(persistor, apiPath.toString(), headers, timeout, msg);
}
 
開發者ID:santo74,項目名稱:vertx-arangodb,代碼行數:17,代碼來源:GenericAPI.java

示例13: test13GetCollectionFigures

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Test
public void test13GetCollectionFigures() {
    System.out.println("*** test13GetCollectionFigures ***");
    JsonObject requestObject = new JsonObject();
    requestObject.putString(ArangoPersistor.MSG_PROPERTY_TYPE, ArangoPersistor.MSG_TYPE_COLLECTION);
    requestObject.putString(CollectionAPI.MSG_PROPERTY_ACTION, CollectionAPI.MSG_ACTION_FIGURES);
    requestObject.putString(CollectionAPI.MSG_PROPERTY_COLLECTION, vertexColName);
    vertx.eventBus().send(address, requestObject, new Handler<Message<JsonObject>>() {
        @Override
        public void handle(Message<JsonObject> reply) {
            try {
                JsonObject response = reply.body();
                System.out.println("response: " + response);
                JsonObject arangoResult = response.getObject("result");
                VertxAssert.assertEquals("Getting figures of the specified collection resulted in an error: " + response.getString("message"), "ok", response.getString("status"));
                System.out.println("response details: " + arangoResult);
            }
            catch (Exception e) {
                VertxAssert.fail("test13GetCollectionFigures");
            }
            VertxAssert.testComplete();
        }
    });
}
 
開發者ID:santo74,項目名稱:vertx-arangodb,代碼行數:25,代碼來源:CollectionIntegrationTest.java

示例14: handle

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Override
public void handle(Message<JsonObject> m) {
	switch(m.body().getString("action")) {
		case "execute" :
			execute(m);
			break;
		case "executeBatch" :
			executeBatch(m);
			break;
		case "executeTransaction" :
			executeTransaction(m);
			break;
		case "resetTransactionTimeout" :
			resetTransaction(m);
			break;
		case "rollbackTransaction" :
			rollbackTransaction(m);
			break;
		case "unmanagedExtension":
			unmanagedExtension(m);
			break;
		default :
			sendError(m, "Invalid or missing action");
	}
}
 
開發者ID:web-education,項目名稱:mod-neo4j-persistor,代碼行數:26,代碼來源:Neo4jPersistor.java

示例15: test13GetVertices

import org.vertx.java.core.eventbus.Message; //導入依賴的package包/類
@Test
public void test13GetVertices() {
    System.out.println("*** test13GetVertices ***");
    JsonObject requestObject = new JsonObject();
    requestObject.putString(ArangoPersistor.MSG_PROPERTY_TYPE, ArangoPersistor.MSG_TYPE_GRAPH);
    requestObject.putString(GraphAPI.MSG_PROPERTY_ACTION, GraphAPI.MSG_ACTION_GET_VERTICES);
    requestObject.putString(GraphAPI.MSG_PROPERTY_GRAPH_NAME, "testgraph");
    requestObject.putString(GraphAPI.MSG_PROPERTY_VERTEX_ID, idVertex01);
    requestObject.putObject(GraphAPI.MSG_PROPERTY_DOCUMENT, new JsonObject());
    vertx.eventBus().send(address, requestObject, new Handler<Message<JsonObject>>() {
        @Override
        public void handle(Message<JsonObject> reply) {
            try {
                JsonObject response = reply.body();
                System.out.println("response: " + response);
                JsonObject arangoResult = response.getObject("result");
                VertxAssert.assertEquals("The graph operation resulted in an error: " + response.getString("message"), "ok", response.getString("status"));
                System.out.println("result details: " + arangoResult);                    
            }
            catch (Exception e) {
                VertxAssert.fail("test13GetVertices");
            }
            VertxAssert.testComplete();
        }
    });
}
 
開發者ID:santo74,項目名稱:vertx-arangodb,代碼行數:27,代碼來源:GraphIntegrationTest.java


注:本文中的org.vertx.java.core.eventbus.Message類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。