Class AnjayDownload


  • public final class AnjayDownload
    extends java.lang.Object
    Manages downloads started by user.
    • Method Detail

      • startDownload

        public static AnjayDownload startDownload​(Anjay anjay,
                                                  AnjayDownload.Configuration config,
                                                  AnjayDownloadHandlers handlers)
                                           throws java.lang.Exception,
                                                  java.util.ConcurrentModificationException
        Requests asynchronous download of an external resource.

        Download will create a new socket that will be later included in the list returned by Anjay.getSockets(). Calling serve on such socket may cause calling onNextBlock if received packet is the next expected chunk of downloaded data and onDownloadFinished if the transfer completes or fails. Request packet retransmissions are managed by Anjay scheduler, and sent by serve.

        Parameters:
        anjay - Anjay instance to be used for performing download.
        config - Download configuration.
        handlers - Implementation of handlers to be called by downloader.
        Returns:
        AnjayDownload object which may be used to abort the download process.
        Throws:
        java.lang.Exception - If config is invalid or download can't be started.
        java.util.ConcurrentModificationException - if the security configuration used AnjaySecurityConfigFromDm and the configuration expired due to Anjay.serve(java.nio.channels.SelectableChannel) or Anjay.schedRun() calls happening in between.
      • abort

        public void abort()
        Abort the ongoing download. Does nothing if the download is already finished.