aQute.bnd.build
Class DownloadBlocker

java.lang.Object
  extended by aQute.bnd.build.DownloadBlocker
All Implemented Interfaces:
RepositoryPlugin.DownloadListener

public class DownloadBlocker
extends Object
implements RepositoryPlugin.DownloadListener

This class is intended to be used by the users of a RepositoryPlugin. The RepositoryPlugin.get(String, aQute.bnd.version.Version, java.util.Map, aQute.bnd.service.RepositoryPlugin.DownloadListener...) method takes one or more Download Listeners. These are called back with the success or failure of a download. This class is a simple implementation of this model, just call getReason() and it blocks until success or failure is called.


Nested Class Summary
static class DownloadBlocker.Stage
           
 
Constructor Summary
DownloadBlocker(Reporter reporter)
           
 
Method Summary
 void failure(File file, String reason)
          Called when the file could not be downloaded from a remote repository.
 File getFile()
           
 String getReason()
          Return a failure reason or null.
 DownloadBlocker.Stage getStage()
          Return the stage we're in
 boolean progress(File file, int percentage)
          Can be called back regularly before success/failure but never after.
 void success(File file)
          Called when the file is successfully downloaded from a remote repository.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DownloadBlocker

public DownloadBlocker(Reporter reporter)
Method Detail

success

public void success(File file)
             throws Exception
Description copied from interface: RepositoryPlugin.DownloadListener
Called when the file is successfully downloaded from a remote repository.

Specified by:
success in interface RepositoryPlugin.DownloadListener
Parameters:
file - The file that was downloaded
Throws:
Exception - , are logged and ignored

failure

public void failure(File file,
                    String reason)
             throws Exception
Description copied from interface: RepositoryPlugin.DownloadListener
Called when the file could not be downloaded from a remote repository.

Specified by:
failure in interface RepositoryPlugin.DownloadListener
Parameters:
file - The file that was intended to be downloaded.
Throws:
Exception - , are logged and ignored

progress

public boolean progress(File file,
                        int percentage)
                 throws Exception
Description copied from interface: RepositoryPlugin.DownloadListener
Can be called back regularly before success/failure but never after. Indicates how far the download has progressed in percents. Since downloads can be restarted, it is possible that the percentage decreases.

Specified by:
progress in interface RepositoryPlugin.DownloadListener
Parameters:
file - The file that was intended to be downloaded
percentage - Percentage of file downloaded (can go down)
Returns:
true if the download should continue, fails if it should be canceled (and fail)
Throws:
Exception - , are logged and ignored

getReason

public String getReason()
Return a failure reason or null. This method will block until either success(File) or failure(File, String) has been called. It can be called many times.

Returns:
null or a reason for a failure

getStage

public DownloadBlocker.Stage getStage()
Return the stage we're in

Returns:
the current stage

getFile

public File getFile()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 aQute SARL. All rights reserved.