Class SDKProgressPublisher


  • public class SDKProgressPublisher
    extends Object
    This class is responsible for executing the callback method of ProgressListener; listener callbacks are executed sequentially in a separate single thread.
    • Constructor Detail

      • SDKProgressPublisher

        public SDKProgressPublisher()
    • Method Detail

      • publishProgress

        public static Future<?> publishProgress​(ProgressListener listener,
                                                ProgressEventType type)
        Used to deliver a progress event to the given listener.
        Returns:
        the future of a submitted task; or null if the delivery is synchronous with no future task involved. Note a listener should never block, and therefore returning null is the typical case.
      • publishRequestContentLength

        public static Future<?> publishRequestContentLength​(ProgressListener listener,
                                                            long bytes)
        Convenient method to publish a request content length event to the given listener.
        Parameters:
        listener - must not be null or else the publication will be skipped
        bytes - must be non-negative or else the publication will be skipped
      • publishResponseContentLength

        public static Future<?> publishResponseContentLength​(ProgressListener listener,
                                                             long bytes)
        Convenient method to publish a response content length event to the given listener.
        Parameters:
        listener - must not be null or else the publication will be skipped
        bytes - must be non-negative or else the publication will be skipped
      • publishRequestBytesTransferred

        public static Future<?> publishRequestBytesTransferred​(ProgressListener listener,
                                                               long bytes)
        Convenient method to publish a request byte transfer event to the given listener.
        Parameters:
        listener - must not be null or else the publication will be skipped
        bytes - must be non-negative or else the publication will be skipped
      • publishResponseBytesTransferred

        public static Future<?> publishResponseBytesTransferred​(ProgressListener listener,
                                                                long bytes)
        Convenient method to publish a response byte transfer event to the given listener.
        Parameters:
        listener - must not be null or else the publication will be skipped
        bytes - must be non-negative or else the publication will be skipped
      • publishRequestReset

        public static Future<?> publishRequestReset​(ProgressListener listener,
                                                    long bytesReset)
        Convenient method to publish a request reset event to the given listener.
        Parameters:
        listener - must not be null or else the publication will be skipped
        bytesReset - must be non-negative or else the publication will be skipped
      • publishResponseReset

        public static Future<?> publishResponseReset​(ProgressListener listener,
                                                     long bytesReset)
        Convenient method to publish a response reset event to the given listener.
      • publishResponseBytesDiscarded

        public static Future<?> publishResponseBytesDiscarded​(ProgressListener listener,
                                                              long bytesDiscarded)
        Convenient method to publish a response bytes discard event to the given listener.
      • getExecutorService

        protected static ExecutorService getExecutorService()
        Returns the executor service used for performing the callbacks.
      • setLatestFutureTask

        protected static Future<?> setLatestFutureTask​(Future<?> f)
      • shutdown

        public static void shutdown​(boolean now)
        Can be used to shutdown the (legacy) executor.

        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.

        Parameters:
        now - true if shutdown now; false otherwise.