List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture()
From source file:io.engagingspaces.graphql.servicediscovery.publisher.SchemaRegistrar.java
License:Open Source License
private void doClose(Handler<AsyncResult<Void>> closeHandler) { super.close(); consumerManager.close();/*from w w w .j a v a 2s. c o m*/ closeHandler.handle(Future.succeededFuture()); }
From source file:io.engagingspaces.graphql.servicediscovery.service.GraphQLService.java
License:Open Source License
/** * Unpublish a GraphQL schema that was previously published. * * @param registration the information of the schema to unpublish * @param resultHandler the result handler *///from w w w .j a v a2 s . c o m static void unpublish(SchemaRegistration registration, Handler<AsyncResult<Void>> resultHandler) { Objects.requireNonNull(registration, "Schema registration cannot be null"); Objects.requireNonNull(resultHandler, "Un-publication result handler cannot be null"); registration.getDiscovery().unpublish(registration.getRecord().getRegistration(), rh -> { if (rh.succeeded()) { registration.unregisterServiceProxy(); resultHandler.handle(Future.succeededFuture()); } else { resultHandler.handle(Future.failedFuture(rh.cause())); } }); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Connect to the server./* w ww .jav a2 s. co m*/ * @param handler callback handler that is called when the connection is completed. */ public void connect(Handler<AsyncResult<Void>> handler) { next = resp(handler, when("220", c -> { handler.handle(Future.succeededFuture()); })); client = vertx.createNetClient(); client.connect(port, host, res -> { socket = res.result(); if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { RecordParser parser = RecordParser.newDelimited("\n", this::output); socket.handler(parser); } }); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Perform a login on the FTP server using the specified user name and password. * @param user the user name//from www . j a va 2 s. c o m * @param passwd the password * @param handler callback handler that is called when the login is completed. */ public void login(String user, String passwd, Handler<AsyncResult<Void>> handler) { write("USER " + user, resp(handler, when("230", u -> { handler.handle(Future.succeededFuture()); }), when("331", "332", u -> { write("PASS " + passwd, resp(handler, when("230", "202", p -> { handler.handle(Future.succeededFuture()); }))); }))); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Perform a retrive (download) of the file by path. * @param path the path to list.//from w ww. j av a 2s .co m * @param localFile an asyncFile where the download file will be written * @param progress a progress handler that is called for each part that is recieved. * @param handler callback handler that is called when the list is completed. */ public void retr(String path, WriteStream<Buffer> localFile, Handler<Progress> progress, Handler<AsyncResult<Void>> handler) { AtomicInteger ends = new AtomicInteger(0); pasv(handler, datasocket -> { datasocket.endHandler($ -> { if (ends.incrementAndGet() == 2) { handler.handle(Future.succeededFuture()); } }); new ProgressPump(datasocket, localFile, pumped -> { progress.handle(new Progress(this, pumped)); }).start(); }, $ -> { write("RETR " + path, resp(handler, when("125", "150", retr -> { handle(resp(handler, when("226", "250", listdone -> { if (ends.incrementAndGet() == 2) { handler.handle(Future.succeededFuture()); } }))); }))); }); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Perform a store (upload) to the file of path. * @param path the path to upload to./* w ww. ja v a2s . c om*/ * @param localFile an asyncFile where the download file will be written * @param progress a progress handler that is called for each part that is recieved. * @param handler callback handler that is called when the list is completed. */ public void stor(String path, ReadStream<Buffer> localFile, Handler<Progress> progress, Handler<AsyncResult<Void>> handler) { AtomicInteger ends = new AtomicInteger(0); pasv(handler, datasocket -> { localFile.endHandler($ -> { datasocket.close(); if (ends.incrementAndGet() == 2) { handler.handle(Future.succeededFuture()); } }); new ProgressPump(localFile, datasocket, pumped -> { progress.handle(new Progress(this, pumped)); }).start(); }, $ -> { write("STOR " + path, resp(handler, when("125", "150", retr -> { handle(resp(handler, when("226", "250", listdone -> { if (ends.incrementAndGet() == 2) { handler.handle(Future.succeededFuture()); } }))); }))); }); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Perform a delete on the server. //ww w. j ava 2 s .c om * @param path the path to upload to. * @param handler callback handler that is called when the list is completed. */ public void dele(String path, Handler<AsyncResult<Void>> handler) { write("DELE " + path, resp(handler, when("250", pasv -> { handler.handle(Future.succeededFuture()); }))); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
/** * Perform a change directory on the server. * @param dir the directory to change into. * @param handler callback handler that is called when the list is completed. *//* ww w. j a va 2s . com*/ public void cwd(String dir, Handler<AsyncResult<Void>> handler) { write("CWD " + dir, resp(handler, when("250", pasv -> { handler.handle(Future.succeededFuture()); }))); }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
public void cdup(Handler<AsyncResult<Void>> handler) { write("CDUP", resp(handler, when("200", pasv -> { handler.handle(Future.succeededFuture()); })));//from w w w . j a v a2s . com }
From source file:io.github.bckfnn.ftp.FtpClient.java
License:Apache License
public void rmd(String dir, Handler<AsyncResult<Void>> handler) { write("RMD " + dir, resp(handler, when("250", pasv -> { handler.handle(Future.succeededFuture()); })));/*from ww w. j a v a 2 s. co m*/ }