本文整理匯總了Java中io.vertx.core.AsyncResult.result方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncResult.result方法的具體用法?Java AsyncResult.result怎麽用?Java AsyncResult.result使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.AsyncResult
的用法示例。
在下文中一共展示了AsyncResult.result方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: afterReadInEventloop
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
private synchronized void afterReadInEventloop(AsyncResult<ReadResult> ar) {
if (ar.failed()) {
exceptionHandler.handle(ar.cause());
return;
}
readInProgress = false;
ReadResult readResult = ar.result();
if (readResult.readed < 0) {
handleEnd();
return;
}
handleData(readResult.toBuffer());
if (!paused && dataHandler != null) {
doRead();
}
}
示例2: handler
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
protected void handler(AsyncResult<?> asyncResult) {
if (asyncResult.failed()) {
log.error("AsyncResult failed", asyncResult.cause());
error(asyncResult.cause());
return;
}
if (asyncResult.result().getClass().equals(Optional.class) && !((Optional) asyncResult.result()).isPresent()) {
noContent();
return;
}
if(asyncResult.result() == null){
success();
}
else{
success(asyncResult.result());
}
}
示例3: doDispatch
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
private <T> void doDispatch(Future<T> future, Buffer buffer, AsyncResult<Record> resultHandler) {
AuditFuture audit = AuditFuture.create(context).saveRequest(buffer.copy());
if (resultHandler.succeeded()) {
Record record = resultHandler.result();
proxyService.proxy(context, record, buffer).setHandler(ar -> {
audit.saveResponse(record, ar.result());
future.complete();
});
} else {
audit.saveResponse(resultHandler.cause());
future.fail(resultHandler.cause());
}
}
示例4: onGetResponse
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
private void onGetResponse(AsyncResult<String> ar) {
if (ar.succeeded()) {
if (ar.result() == null) {
createCache();
return;
}
future.complete(ar.result());
return;
}
future.completeExceptionally(ar.cause());
}
示例5: processResponse
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
private JsonArray processResponse(final Range range,
final Function<Range, List<Range>> rangeSplitter,
final JsonArray targets,
final AsyncResult<List<JsonObject>> result) {
final List<Range> intervals = rangeSplitter.apply(range);
final List<JsonObject> datapoints = result.result();
return targets.stream()
.parallel()
.map(Object::toString)
.flatMap(targetName -> calculatePecentileForTarget(targetName, intervals, datapoints))
.collect(new DatapointsResultCollector());
}
示例6: handle
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
public void handle(AsyncResult<NetSocket> result) {
NetSocket socket = result.result();
//read data
socket.handler(new Handler<Buffer>(){
@Override
public void handle(Buffer buffer) {
System.out.println("Received data length: " + buffer.length());
String data = buffer.getString(0, buffer.length());
System.out.println("Received data: " + data);
}
});
// JsonObject jsonObject = new JsonObject();
// for (int i = 0; i < 500; i++){
// jsonObject.put("" + i, i);
// }
// FrameHelper.writeFrame(jsonObject, socket);
PersonDomain.Person.Builder builder = PersonDomain.Person.newBuilder();
builder.setId(1);
builder.setName("zzqfsy");
builder.setEmail("[email protected]");
PersonDomain.Person person = builder.build();
FrameHelper.writeFrame(person.toByteArray(), socket);
socket.exceptionHandler(t -> {
System.out.println(t.getMessage());
socket.close();
});
socket.endHandler(v -> {
});
}
示例7: success
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
protected Envelop success(final String address,
final AsyncResult<Message<Envelop>> handler
) {
Envelop envelop;
try {
final Message<Envelop> message = handler.result();
envelop = message.body();
} catch (final Throwable ex) {
final WebException error
= new _500EntityCastException(this.getClass(),
address, ex.getMessage());
envelop = Envelop.failure(error);
}
return envelop;
}
示例8: handle
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
@Override
public void handle(AsyncResult<Connection> ar) {
if (ar.succeeded()) {
Connection conn = ar.result();
this.conn = conn;
conn.init(this);
onSuccess(conn);
} else {
onFailure(ar.cause());
}
}
示例9: handle
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
@Override
public void handle(AsyncResult<Boolean> res) {
if (res.failed()) {
cursor = null;
Handler<Throwable> handler = exceptionHandler;
if (handler != null) {
handler.handle(res.cause());
}
close();
} else {
this.suspended = res.result();
checkPending();
}
}
示例10: handle
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
@Override
public void handle(AsyncResult<Connection> ar) {
if (ar.succeeded()) {
conn = ar.result();
} else {
acquireFailure = ar.cause();
}
}
示例11: onPublish
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
protected void onPublish(AsyncResult<Record> resultHandler) {
if (resultHandler.succeeded()) {
record = resultHandler.result();
log.info("{} microservice registered on ServiceDiscovery", resultHandler.result().getName());
} else {
log.error("Fail to registry microservice, fall out of process", resultHandler.cause());
System.exit(CommonExitCode.REGISTRY_SERVICE_DISCOVERY_ERROR);
}
}
示例12: handleAuthentication
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
private void handleAuthentication(AsyncResult<JsonObject> resultHandler) {
if (resultHandler.failed()) {
unauthorized(resultHandler.cause());
return;
}
JsonObject jwtOptions = vertx.getOrCreateContext().config().getJsonObject("jwtOptions", new JsonObject().put("expiresInSeconds", 60));
JWTOptions options = new JWTOptions().setExpiresInSeconds(jwtOptions.getLong("expiresInSeconds"));
JsonObject user = resultHandler.result();
String jwt = jwtAuth.getJWTAuth().generateToken(user, options);
success(new JsonObject().put("jwt", jwt));
}
示例13: handle
import io.vertx.core.AsyncResult; //導入方法依賴的package包/類
@Override
public void handle(AsyncResult<Boolean> res) {
suspended = res.result();
handler.handle(res.map(result));
}