1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 package com.zeroc.Ice; 6 7 import java.util.concurrent.CompletableFuture; 8 import java.util.concurrent.Executor; 9 10 /** 11 * An instance of an InvocationFuture subclass is the return value of an asynchronous invocation. 12 * With this object, an application can obtain several attributes of the invocation. 13 **/ 14 public abstract class InvocationFuture<T> extends CompletableFuture<T> 15 { 16 /** 17 * If not completed, cancels the request. This is a local 18 * operation, it won't cancel the request on the server side. 19 * Calling <code>cancel</code> prevents a queued request from 20 * being sent or ignores a reply if the request has already 21 * been sent. 22 * 23 * @return True if this task is now cancelled. 24 **/ cancel()25 public abstract boolean cancel(); 26 27 /** 28 * Returns the communicator that sent the invocation. 29 * 30 * @return The communicator. 31 **/ getCommunicator()32 public abstract Communicator getCommunicator(); 33 34 /** 35 * Returns the connection that was used to start the invocation, or nil 36 * if this future was not obtained via an asynchronous connection invocation 37 * (such as <code>flushBatchRequestsAsync</code>). 38 * 39 * @return The connection. 40 **/ getConnection()41 public abstract Connection getConnection(); 42 43 /** 44 * Returns the proxy that was used to start the asynchronous invocation, or nil 45 * if this object was not obtained via an asynchronous proxy invocation. 46 * 47 * @return The proxy. 48 **/ getProxy()49 public abstract ObjectPrx getProxy(); 50 51 /** 52 * Returns the name of the operation. 53 * 54 * @return The operation name. 55 **/ getOperation()56 public abstract String getOperation(); 57 58 /** 59 * Blocks the caller until the result of the invocation is available. 60 **/ waitForCompleted()61 public abstract void waitForCompleted(); 62 63 /** 64 * When you start an asynchronous invocation, the Ice run time attempts to 65 * write the corresponding request to the client-side transport. If the 66 * transport cannot accept the request, the Ice run time queues the request 67 * for later transmission. This method returns true if, at the time it is called, 68 * the request has been written to the local transport (whether it was initially 69 * queued or not). Otherwise, if the request is still queued, this method returns 70 * false. 71 * 72 * @return True if the request has been sent, or false if the request is queued. 73 **/ isSent()74 public abstract boolean isSent(); 75 76 /** 77 * Blocks the caller until the request has been written to the client-side transport. 78 **/ waitForSent()79 public abstract void waitForSent(); 80 81 /** 82 * Returns true if a request was written to the client-side 83 * transport without first being queued. If the request was initially 84 * queued, this method returns false (independent of whether the request 85 * is still in the queue or has since been written to the client-side transport). 86 * 87 * @return True if the request was sent without being queued, or false 88 * otherwise. 89 **/ sentSynchronously()90 public abstract boolean sentSynchronously(); 91 92 /** 93 * Returns a future that completes when the entire request message has been 94 * accepted by the transport and executes the given action. The boolean value 95 * indicates whether the message was sent synchronously. 96 * 97 * @param action Executed when the future is completed successfully or exceptionally. 98 * @return A future that completes when the message has been handed off to the transport. 99 **/ whenSent( java.util.function.BiConsumer<Boolean, ? super Throwable> action)100 public abstract CompletableFuture<Boolean> whenSent( 101 java.util.function.BiConsumer<Boolean, ? super Throwable> action); 102 103 /** 104 * Returns a future that completes when the entire request message has been 105 * accepted by the transport and executes the given action using the default executor. The boolean value 106 * indicates whether the message was sent synchronously. 107 * 108 * @param action Executed when the future is completed successfully or exceptionally. 109 * @return A future that completes when the message has been handed off to the transport. 110 **/ whenSentAsync( java.util.function.BiConsumer<Boolean, ? super Throwable> action)111 public abstract CompletableFuture<Boolean> whenSentAsync( 112 java.util.function.BiConsumer<Boolean, ? super Throwable> action); 113 114 /** 115 * Returns a future that completes when the entire request message has been 116 * accepted by the transport and executes the given action using the executor. The boolean value 117 * indicates whether the message was sent synchronously. 118 * 119 * @param action Executed when the future is completed successfully or exceptionally. 120 * @param executor The executor to use for asynchronous execution. 121 * @return A future that completes when the message has been handed off to the transport. 122 **/ whenSentAsync( java.util.function.BiConsumer<Boolean, ? super Throwable> action, Executor executor)123 public abstract CompletableFuture<Boolean> whenSentAsync( 124 java.util.function.BiConsumer<Boolean, ? super Throwable> action, 125 Executor executor); 126 } 127