public class DownloadBlocker extends java.lang.Object implements RepositoryPlugin.DownloadListener
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.Modifier and Type | Class and Description |
---|---|
static class |
DownloadBlocker.Stage |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
failure |
private java.io.File |
file |
private static org.slf4j.Logger |
logger |
private Reporter |
reporter |
private java.util.concurrent.CountDownLatch |
resolved |
private DownloadBlocker.Stage |
stage |
Constructor and Description |
---|
DownloadBlocker(Reporter reporter) |
Modifier and Type | Method and Description |
---|---|
void |
failure(java.io.File file,
java.lang.String reason)
Called when the file could not be downloaded from a remote
repository.
|
java.io.File |
getFile() |
java.lang.String |
getReason()
Return a failure reason or null.
|
DownloadBlocker.Stage |
getStage()
Return the stage we're in
|
boolean |
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.
|
java.lang.String |
toString() |
private static final org.slf4j.Logger logger
private volatile DownloadBlocker.Stage stage
private java.lang.String failure
private java.io.File file
private final Reporter reporter
private final java.util.concurrent.CountDownLatch resolved
public DownloadBlocker(Reporter reporter)
public void success(java.io.File file) throws java.lang.Exception
RepositoryPlugin.DownloadListener
success
in interface RepositoryPlugin.DownloadListener
file
- The file that was downloadedjava.lang.Exception
- , are logged and ignoredpublic void failure(java.io.File file, java.lang.String reason) throws java.lang.Exception
RepositoryPlugin.DownloadListener
failure
in interface RepositoryPlugin.DownloadListener
file
- The file that was intended to be downloaded.java.lang.Exception
- , are logged and ignoredpublic boolean progress(java.io.File file, int percentage) throws java.lang.Exception
RepositoryPlugin.DownloadListener
progress
in interface RepositoryPlugin.DownloadListener
file
- The file that was intended to be downloadedpercentage
- Percentage of file downloaded (can go down)java.lang.Exception
- , are logged and ignoredpublic java.lang.String getReason()
success(File)
or failure(File, String)
has been called.
It can be called many times.public DownloadBlocker.Stage getStage()
public java.io.File getFile()
public java.lang.String toString()
toString
in class java.lang.Object