Search in sources :

Example 1 with DownloadListenerPromise

use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.

the class BndPomRepository method get.

@Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
    init();
    ResourceInfo resource = bridge.getInfo(bsn, version);
    if (resource == null)
        return null;
    String name = resource.getInfo().name();
    Archive archive = Archive.valueOf(name);
    Promise<File> p = repoImpl.getMavenRepository().get(archive);
    if (listeners.length == 0)
        return p.getValue();
    new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version, p, listeners);
    return repoImpl.getMavenRepository().toLocalFile(archive);
}
Also used : ResourceInfo(aQute.bnd.osgi.repository.BridgeRepository.ResourceInfo) Archive(aQute.maven.api.Archive) DownloadListenerPromise(aQute.bnd.util.repository.DownloadListenerPromise) File(java.io.File)

Example 2 with DownloadListenerPromise

use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.

the class OSGiRepository method get.

@Override
public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
    File target = IO.getFile(getIndex().getCache(), bsn + "-" + version + ".jar");
    Promise<File> promise = getIndex().get(bsn, version, target);
    if (promise == null)
        return null;
    if (listeners.length == 0) {
        return promise.getValue();
    }
    new DownloadListenerPromise(reporter, "Download " + bsn + "-" + version + " into " + config.name(), promise, listeners);
    return target;
}
Also used : DownloadListenerPromise(aQute.bnd.util.repository.DownloadListenerPromise) File(java.io.File)

Example 3 with DownloadListenerPromise

use of aQute.bnd.util.repository.DownloadListenerPromise in project bnd by bndtools.

the class P2Indexer method get.

File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception {
    Resource resource = getBridge().get(bsn, version);
    if (resource == null)
        return null;
    ContentCapability contentCapability = ResourceUtils.getContentCapability(resource);
    if (contentCapability == null)
        return null;
    URI url = contentCapability.url();
    final File source = client.getCacheFileFor(url);
    final File link = new File(location, bsn + "-" + version + ".jar");
    IO.createSymbolicLinkOrCopy(link, source);
    Promise<File> go = client.build().useCache(MAX_STALE).async(url.toURL()).map(new Function<File, File>() {

        @Override
        public File apply(File t) {
            return link;
        }
    });
    if (listeners.length == 0)
        return go.getValue();
    new DownloadListenerPromise(reporter, name + ": get " + bsn + ";" + version + " " + url, go, listeners);
    return link;
}
Also used : Resource(org.osgi.resource.Resource) DownloadListenerPromise(aQute.bnd.util.repository.DownloadListenerPromise) URI(java.net.URI) File(java.io.File) ContentCapability(aQute.bnd.osgi.resource.ResourceUtils.ContentCapability)

Aggregations

DownloadListenerPromise (aQute.bnd.util.repository.DownloadListenerPromise)3 File (java.io.File)3 ResourceInfo (aQute.bnd.osgi.repository.BridgeRepository.ResourceInfo)1 ContentCapability (aQute.bnd.osgi.resource.ResourceUtils.ContentCapability)1 Archive (aQute.maven.api.Archive)1 URI (java.net.URI)1 Resource (org.osgi.resource.Resource)1