Package aQute.bnd.build
Class DownloadBlocker
- java.lang.Object
-
- aQute.bnd.build.DownloadBlocker
-
- All Implemented Interfaces:
RepositoryPlugin.DownloadListener
public class DownloadBlocker extends java.lang.Object implements RepositoryPlugin.DownloadListener
This class is intended to be used by the users of aRepositoryPlugin
. TheRepositoryPlugin.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 callgetReason()
and it blocks until success or failure is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DownloadBlocker.Stage
-
Constructor Summary
Constructors Constructor Description DownloadBlocker(aQute.service.reporter.Reporter reporter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
failure(java.io.File file, java.lang.String reason)
Called when the file could not be downloaded from a remote repository.java.util.Map<java.lang.String,java.lang.String>
getAttributes()
java.io.File
getFile()
java.lang.String
getReason()
Return a failure reason or null.DownloadBlocker.Stage
getStage()
Return the stage we're inboolean
progress(java.io.File file, int percentage)
Can be called back regularly before success/failure but never after.void
success(java.io.File file)
Called when the file is successfully downloaded from a remote repository.void
success(java.io.File file, java.util.Map<java.lang.String,java.lang.String> attrs)
Called when the file is successfully downloaded from a remote repository.java.lang.String
toString()
-
-
-
Method Detail
-
success
public void success(java.io.File file) throws java.lang.Exception
Description copied from interface:RepositoryPlugin.DownloadListener
Called when the file is successfully downloaded from a remote repository.- Specified by:
success
in interfaceRepositoryPlugin.DownloadListener
- Parameters:
file
- The file that was downloaded- Throws:
java.lang.Exception
- , are logged and ignored
-
success
public void success(java.io.File file, java.util.Map<java.lang.String,java.lang.String> attrs) throws java.lang.Exception
Description copied from interface:RepositoryPlugin.DownloadListener
Called when the file is successfully downloaded from a remote repository.- Specified by:
success
in interfaceRepositoryPlugin.DownloadListener
- Parameters:
file
- The file that was downloadedattrs
- Additional attributes about the file. This may include maven coordinates.- Throws:
java.lang.Exception
- , are logged and ignored
-
failure
public void failure(java.io.File file, java.lang.String reason) throws java.lang.Exception
Description copied from interface:RepositoryPlugin.DownloadListener
Called when the file could not be downloaded from a remote repository.- Specified by:
failure
in interfaceRepositoryPlugin.DownloadListener
- Parameters:
file
- The file that was intended to be downloaded.- Throws:
java.lang.Exception
- , are logged and ignored
-
progress
public boolean progress(java.io.File file, int percentage) throws java.lang.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 interfaceRepositoryPlugin.DownloadListener
- Parameters:
file
- The file that was intended to be downloadedpercentage
- Percentage of file downloaded (can go down)- Returns:
- true if the download should continue, fails if it should be canceled (and fail)
- Throws:
java.lang.Exception
- , are logged and ignored
-
getReason
public java.lang.String getReason()
Return a failure reason or null. This method will block until eithersuccess(File)
orfailure(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 java.io.File getFile()
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-