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


Java AsyncResult類代碼示例

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


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

示例1: getResidualRepositorySize

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
private void getResidualRepositorySize(final Handler<Long> handler) {
	storage.stats(new AsyncResultHandler<BucketStats>() {
		@Override
		public void handle(AsyncResult<BucketStats> event) {
			Long residualRepositorySize = 0L;
			if (event.succeeded()) {
				final Long sizeUsed = event.result().getStorageSize();
				final Long residualRepository = ShareBigFilesController.this.maxRepositoryQuota - sizeUsed;
				residualRepositorySize = (residualRepository < 0) ? 0L : residualRepository;
			} else {
				log.error("Can't get the repository stats : ", event.cause());
			}
			handler.handle(residualRepositorySize);
		}
	});
}
 
開發者ID:OPEN-ENT-NG,項目名稱:share-big-files,代碼行數:17,代碼來源:ShareBigFilesController.java

示例2: testDeployment

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testDeployment() throws InterruptedException {

    JsonObject config = createBaseConfig();
    config.putString(CONF_KEY_LOCAL_ADDRESS, LOCAL_ADDRESS);

    container.deployWorkerVerticle(Activator.class.getName(), config, 3, false,
            new AsyncResultHandler<String>() {
                @Override
                public void handle(final AsyncResult<String> ar) {
                    if (ar.succeeded()) {
                        initActivator(ar.result());
                    } else {
                        m_logger.error("Failed to deploy verticle: {}", ar.cause());
                        Assert.fail();
                    }
                }
            }
    );

    vertx.setPeriodic(1500L, this); // Generate events once every 500 ms
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:23,代碼來源:ActivatorTest.java

示例3: handle

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void handle(final Long timerId) {

    final FileSystem fs = m_fileSystem;
    final List<Path> paths = m_paths; // file paths

    for (final Path path : paths) {

        m_logger.trace("Inspecting file: {}", path);

        // Check that file exists before proceeding further...
        if (Files.exists(path)) {

            fs.props(path.toString(), new AsyncResultHandler<FileProps>() {

                @Override
                public void handle(final AsyncResult<FileProps> ar) {
                    handleFileProps(ar, path);
                }
            });
        }
    }
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:24,代碼來源:AsyncFileWatcher.java

示例4: testSqlView

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testSqlView() throws ResourceException {

    vertx.eventBus().registerLocalHandler(FILTER_DEST_ADDRESS, this);

    JsonObject config = createBaseConfig();
    config.mergeIn(loadSqlConfig(config));

    // Update interval (how often to read the database)
    config.putNumber(CONF_KEY_UPDATE_INTERVAL, 500L);
    m_logger.info("Update interval: {}", config.getLong(CONF_KEY_UPDATE_INTERVAL));

    container.deployWorkerVerticle(Sql.class.getName(), config, 1, false,
            new AsyncResultHandler<String>() {
                @Override
                public void handle(final AsyncResult<String> ar) {
                    if (ar.failed()) {
                        m_logger.error("Failed to deploy verticle", ar.cause());
                        Assert.fail();
                    }
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:24,代碼來源:SqlInTest.java

示例5: execOutputCommand

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
private void execOutputCommand(final JsonObject config) {

        container.deployVerticle(Command.class.getName(), config, 1,
                new AsyncResultHandler<String>() {
                    @Override
                    public void handle(final AsyncResult<String> ar) {
                        if (ar.succeeded()) {
                            // Emit event
                            JsonObject event = EventCreator.create("Command");
                            vertx.eventBus().publish(EVENT_SRC_ADDRESS, event);
                            //
                            // Stop test
                            //
                            VertxAssert.testComplete();
                        } else {
                            m_logger.error("Failed to deploy verticle", ar.cause());
                            Assert.fail();
                        }
                    }
                });
    }
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:22,代碼來源:CommandTest.java

示例6: execute

import org.vertx.java.core.AsyncResult; //導入依賴的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

示例7: handle

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void handle(AsyncResult<String> ar) {

    if (ar.succeeded()) {
        String deploymentId = ar.result();
        m_logger.debug("Deployment identifier: {}", deploymentId);
        m_modules.put(m_groupArtifactId,
                new Module(
                        m_groupArtifactId,
                        m_artifactVersion,
                        m_localAddress,
                        deploymentId)
        );
        m_latch.countDown();
    } else {
        throw new RuntimeException("Failed to deploy module: "
                + m_moduleId, ar.cause());
    }
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:20,代碼來源:Main.java

示例8: testCommand

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testCommand() throws InterruptedException {

    JsonObject config = new JsonObject();
    config.putValue(CONF_KEY_HOME_PATH, ".");
    config.putValue(CONF_KEY_CONF_PATH, ".");
    config.putValue(CONF_KEY_DATA_PATH, ".");
    config.putValue(CONF_KEY_TMP_PATH, ".");
    config.putValue(CONF_KEY_LOCAL_ADDRESS, LOCAL_ADDRESS);

    container.deployWorkerVerticle(Activator.class.getName(), config, 1, false,
            new AsyncResultHandler<String>() {
                @Override
                public void handle(final AsyncResult<String> ar) {
                    if (ar.failed()) {
                        Assert.fail("Failed to deploy verticle: " + ar.cause());
                    } else {
                        initActivator(ar.result());
                    }
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:23,代碼來源:ActivatorTest.java

示例9: testActivator

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testActivator() {

    JsonObject config = createBaseConfig();

    container.deployWorkerVerticle(Activator.class.getName(), config, 1, false,
            new AsyncResultHandler<String>() {
                @Override
                public void handle(final AsyncResult<String> ar) {
                    if (ar.succeeded()) {

                        // Stop test
                        VertxAssert.testComplete();

                    } else {
                        m_logger.error("Failed to deploy verticle", ar.cause());
                        Assert.fail();
                    }
                }
            });
}
 
開發者ID:clidev,項目名稱:spike.x,代碼行數:22,代碼來源:OshiTest.java

示例10: startServer

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
/**
 * Start an embedded HTTP server
 *
 * @param activeProfilers The active profilers
 * @param port The port on which to bind the server
 */
public static void startServer(final Map<String, ScheduledFuture<?>> runningProfilers, final Map<String, Profiler> activeProfilers, final int port, final AtomicReference<Boolean> isRunning, final List<String> errors) {
    final HttpServer server = VERTX.createHttpServer();
    server.requestHandler(RequestHandler.getMatcher(runningProfilers, activeProfilers, isRunning, errors));
    server.listen(port, new Handler<AsyncResult<HttpServer>>() {
        @Override
        public void handle(AsyncResult<HttpServer> event) {
            if (event.failed()) {
                server.close();
                startServer(runningProfilers, activeProfilers, port + 1, isRunning, errors);
            } else if (event.succeeded()) {
                LOGGER.info("Profiler server started on port " + port);
            }
        }
    });
}
 
開發者ID:etsy,項目名稱:statsd-jvm-profiler,代碼行數:22,代碼來源:ProfilerServer.java

示例11: start

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void start(final Future<Void> startedResult) {
    container.deployVerticle("net.zyclonite.vertx.NetSocketVerticle", new AsyncResultHandler<String>() {
        public void handle(AsyncResult<String> deployResult) {
            if (deployResult.succeeded()) {
                startedResult.setResult(null);
            } else {
                startedResult.setFailure(deployResult.cause());
            }
        }
    });
    container.deployVerticle("net.zyclonite.vertx.HttpVerticle");
    container.deployVerticle("net.zyclonite.vertx.WebSocketVerticle");
    container.deployVerticle("JavaScriptVerticle.js");
    container.deployVerticle("ClosureVerticle.clj");
}
 
開發者ID:bwinparty,項目名稱:HelloVertX,代碼行數:17,代碼來源:ApplicationVerticle.java

示例12: read

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void read(String src, final Handler<ImageFile> handler) {
	String [] path = parsePath(src);
	if (path == null || path.length != 2) {
		handler.handle(null);
		return;
	}
	client.readFile(path[1], path[0], new AsyncResultHandler<StorageObject>() {
		@Override
		public void handle(AsyncResult<StorageObject> event) {
			if (event.succeeded()) {
				StorageObject f = event.result();
				handler.handle(new ImageFile(
						f.getBuffer().getBytes(),
						f.getFilename(),
						f.getContentType()
				));
			} else {
				handler.handle(null);
			}
		}
	});
}
 
開發者ID:web-education,項目名稱:mod-image-resizer,代碼行數:24,代碼來源:SwiftAccess.java

示例13: write

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void write(String dest, ImageFile img, final Handler<String> handler) {
	String [] path = parsePath(dest);
	if (path == null || path.length < 1) {
		handler.handle(null);
		return;
	}
	StorageObject o;
	if (path.length == 2 && path[1] != null && !path[1].trim().isEmpty()) {
		o = new StorageObject(path[1], new Buffer(img.getData()),
				img.getFilename(), img.getContentType());
	} else {
		o = new StorageObject(new Buffer(img.getData()),
				img.getFilename(), img.getContentType());
	}
	client.writeFile(o, path[0], new AsyncResultHandler<String>() {
		@Override
		public void handle(AsyncResult<String> event) {
			if (event.succeeded()) {
				handler.handle(event.result());
			} else {
				handler.handle(null);
			}
		}
	});
}
 
開發者ID:web-education,項目名稱:mod-image-resizer,代碼行數:27,代碼來源:SwiftAccess.java

示例14: handle

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
/**
 * Handle the event bus reply.
 *
 * @param event The event
 */
@Override
public void handle(final AsyncResult<Message<Object>> event) {
	EventBusBridgeResponse response = new EventBusBridgeResponse();
	response.setSuccessful(event.succeeded());
	response.setAddress(address);
	if (event.succeeded()) {
		Message<Object> result = event.result();

		Object responseMessage = result.body();
		response.setResponseMessage(EventBusMessageTypeConverter.convertOutgoingMessage(result.body()));
		response.setEventBusMessageType(EventBusMessageType.lookupByClass(responseMessage.getClass()));
	} else {
		Throwable cause = event.cause();
		if (cause != null) {
			if (cause instanceof ReplyException) {
				ReplyException replyException = (ReplyException) cause;
				response.setCause(replyException.failureType().name());
			} else {
				response.setCause(cause.getMessage());
			}
		}
	}
	postResponse(response);
}
 
開發者ID:j2ro,項目名稱:mod-http-event-bus-bridge,代碼行數:30,代碼來源:HttpResponseHandler.java

示例15: start

import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
  public void start(final Future<Void> startedResult) {
try {
	InputStream input = MessageSendWithReplyTest.class.getResourceAsStream("/config/integration-test-config.json");
	String configString;

	configString = IOUtils.toString(input, Charset.defaultCharset());

	config = new JsonObject(configString);
	url = HttpRequestHelper.constructUrlStringFromConfig(config, EventBusInstruction.send);
	System.out.println("URL: " + url);
       container.deployVerticle(JerseyModule.class.getName(), config, new Handler<AsyncResult<String>>() {	        
		public void handle(AsyncResult<String> event) {
			if (event.succeeded()) {
				startedResult.setResult(null);
				MessageSendWithReplyTest.super.start();
			} else {
				startedResult.setFailure(event.cause());
			}
		}	         					
        });

} catch (IOException e) {
	startedResult.setFailure(e);
}
  }
 
開發者ID:j2ro,項目名稱:mod-http-event-bus-bridge,代碼行數:27,代碼來源:MessageSendWithReplyTest.java


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