public class SDKProgressPublisher
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
SDKProgressPublisher.LazyHolder
Used to avoid creating the extra thread until absolutely necessary.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.concurrent.Future<?> |
latestFutureTask
Used for testing purposes only.
|
Constructor and Description |
---|
SDKProgressPublisher() |
Modifier and Type | Method and Description |
---|---|
private static java.util.concurrent.Future<?> |
deliverEvent(ProgressListener listener,
ProgressEvent event) |
protected static java.util.concurrent.ExecutorService |
getExecutorService()
Returns the executor service used for performing the callbacks.
|
private static java.util.concurrent.Future<?> |
publishByteCountEvent(ProgressListener listener,
ProgressEventType type,
long bytes) |
static java.util.concurrent.Future<?> |
publishProgress(ProgressListener listener,
ProgressEventType type)
Used to deliver a progress event to the given listener.
|
static java.util.concurrent.Future<?> |
publishRequestBytesTransferred(ProgressListener listener,
long bytes)
Convenient method to publish a request byte transfer event to the given
listener.
|
static java.util.concurrent.Future<?> |
publishRequestContentLength(ProgressListener listener,
long bytes)
Convenient method to publish a request content length event to the given
listener.
|
static java.util.concurrent.Future<?> |
publishRequestReset(ProgressListener listener,
long bytesReset)
Convenient method to publish a request reset event to the given listener.
|
private static java.util.concurrent.Future<?> |
publishResetEvent(ProgressListener listener,
ProgressEventType resetEventType,
long bytesReset) |
static java.util.concurrent.Future<?> |
publishResponseBytesDiscarded(ProgressListener listener,
long bytesDiscarded)
Convenient method to publish a response bytes discard event to the given listener.
|
static java.util.concurrent.Future<?> |
publishResponseBytesTransferred(ProgressListener listener,
long bytes)
Convenient method to publish a response byte transfer event to the given
listener.
|
static java.util.concurrent.Future<?> |
publishResponseContentLength(ProgressListener listener,
long bytes)
Convenient method to publish a response content length event to the given
listener.
|
static java.util.concurrent.Future<?> |
publishResponseReset(ProgressListener listener,
long bytesReset)
Convenient method to publish a response reset event to the given listener.
|
private static java.util.concurrent.Future<?> |
quietlyCallListener(ProgressListener listener,
ProgressEvent event) |
protected static java.util.concurrent.Future<?> |
setLatestFutureTask(java.util.concurrent.Future<?> f) |
static void |
shutdown(boolean now)
Can be used to shutdown the (legacy) executor.
|
static void |
waitTillCompletion()
Deprecated.
|
private static volatile java.util.concurrent.Future<?> latestFutureTask
public static java.util.concurrent.Future<?> publishProgress(ProgressListener listener, ProgressEventType type)
private static java.util.concurrent.Future<?> deliverEvent(ProgressListener listener, ProgressEvent event)
private static java.util.concurrent.Future<?> quietlyCallListener(ProgressListener listener, ProgressEvent event)
public static java.util.concurrent.Future<?> publishRequestContentLength(ProgressListener listener, long bytes)
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skippedpublic static java.util.concurrent.Future<?> publishResponseContentLength(ProgressListener listener, long bytes)
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skippedpublic static java.util.concurrent.Future<?> publishRequestBytesTransferred(ProgressListener listener, long bytes)
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skippedpublic static java.util.concurrent.Future<?> publishResponseBytesTransferred(ProgressListener listener, long bytes)
listener
- must not be null or else the publication will be skippedbytes
- must be non-negative or else the publication will be skippedprivate static java.util.concurrent.Future<?> publishByteCountEvent(ProgressListener listener, ProgressEventType type, long bytes)
public static java.util.concurrent.Future<?> publishRequestReset(ProgressListener listener, long bytesReset)
listener
- must not be null or else the publication will be skippedbytesReset
- must be non-negative or else the publication will be skippedpublic static java.util.concurrent.Future<?> publishResponseReset(ProgressListener listener, long bytesReset)
public static java.util.concurrent.Future<?> publishResponseBytesDiscarded(ProgressListener listener, long bytesDiscarded)
private static java.util.concurrent.Future<?> publishResetEvent(ProgressListener listener, ProgressEventType resetEventType, long bytesReset)
listener
- must not be null or else the publication will be skippedbytesReset
- the publication will be skipped unless the number of bytes
reset is positiveprotected static java.util.concurrent.ExecutorService getExecutorService()
protected static java.util.concurrent.Future<?> setLatestFutureTask(java.util.concurrent.Future<?> f)
@Deprecated public static void waitTillCompletion() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public static void shutdown(boolean now)
However, the recommended best practice is to always make use of progress
listeners that are short-lived (ie do not block) and are subclasses of
either SyncProgressListener
or
S3SyncProgressListener
. That way, the progress publisher
(legacy) thread will never be activated in the first place.
now
- true if shutdown now; false otherwise.