com.ning.http.client.providers.jdk
public class JDKFuture<V> extends AbstractListenableFuture<V>
Modifier and Type | Field and Description |
---|---|
protected AsyncHandler<V> |
asyncHandler |
protected java.util.concurrent.atomic.AtomicBoolean |
cancelled |
protected java.util.concurrent.atomic.AtomicBoolean |
contentProcessed |
protected java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> |
exception |
protected java.util.concurrent.Future<V> |
innerFuture |
protected java.util.concurrent.atomic.AtomicBoolean |
isDone |
protected int |
responseTimeoutInMs |
protected java.util.concurrent.atomic.AtomicBoolean |
timedOut |
protected java.util.concurrent.atomic.AtomicLong |
touch |
protected java.net.HttpURLConnection |
urlConnection |
Constructor and Description |
---|
JDKFuture(AsyncHandler<V> asyncHandler,
int responseTimeoutInMs,
java.net.HttpURLConnection urlConnection) |
Modifier and Type | Method and Description |
---|---|
void |
abort(java.lang.Throwable t)
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
content(V v)
Set the content that will be returned by this instance
|
void |
done(java.util.concurrent.Callable callable)
Execute a
Callable and if there is no exception, mark this Future as done and release the internal lock. |
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
getAndSetWriteBody(boolean writeBody)
Write the
Request body |
boolean |
getAndSetWriteHeaders(boolean writeHeaders)
Write the
Request headers |
boolean |
hasExpired()
Is the Future still valid
|
boolean |
isCancelled() |
boolean |
isDone() |
protected void |
setInnerFuture(java.util.concurrent.Future<V> innerFuture) |
void |
touch()
Touch the current instance to prevent external service to times out.
|
addListener, done
protected java.util.concurrent.Future<V> innerFuture
protected final AsyncHandler<V> asyncHandler
protected final int responseTimeoutInMs
protected final java.util.concurrent.atomic.AtomicBoolean cancelled
protected final java.util.concurrent.atomic.AtomicBoolean timedOut
protected final java.util.concurrent.atomic.AtomicBoolean isDone
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> exception
protected final java.util.concurrent.atomic.AtomicLong touch
protected final java.util.concurrent.atomic.AtomicBoolean contentProcessed
protected final java.net.HttpURLConnection urlConnection
public JDKFuture(AsyncHandler<V> asyncHandler, int responseTimeoutInMs, java.net.HttpURLConnection urlConnection)
protected void setInnerFuture(java.util.concurrent.Future<V> innerFuture)
public void done(java.util.concurrent.Callable callable)
ListenableFuture
Callable
and if there is no exception, mark this Future as done and release the internal lock.public void abort(java.lang.Throwable t)
ListenableFuture
public void content(V v)
ListenableFuture
v
- the content that will be returned by this instancepublic boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
public boolean isDone()
public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public boolean hasExpired()
true
if response has expired and should be terminated.public void touch()
public boolean getAndSetWriteHeaders(boolean writeHeaders)
Request
headerspublic boolean getAndSetWriteBody(boolean writeBody)
Request
bodyCopyright © 2014. All Rights Reserved.