Search in sources :

Example 1 with AggregateRepository

use of aQute.bnd.osgi.repository.AggregateRepository in project bnd by bndtools.

the class BndrunResolveContext method loadRepositories.

/**
	 * Load all the OSGi repositories from our registry
	 * <p>
	 * TODO Use Instruction ...
	 *
	 * @return
	 * @throws Exception
	 */
private Processor loadRepositories() throws Exception {
    //
    // Get all of the repositories from the plugin registry
    //
    List<Repository> allRepos = registry.getPlugins(Repository.class);
    Collection<Repository> orderedRepositories;
    String rn = properties.mergeProperties(Constants.RUNREPOS);
    if (rn == null) {
        //
        // No filter set, so we use all
        //
        orderedRepositories = allRepos;
    } else {
        Parameters repoNames = new Parameters(rn, project);
        // Map the repository names...
        Map<String, Repository> repoNameMap = new HashMap<String, Repository>(allRepos.size());
        for (Repository repo : allRepos) {
            String name;
            if (repo instanceof aQute.bnd.deployer.repository.wrapper.Plugin) {
                @SuppressWarnings("resource") aQute.bnd.deployer.repository.wrapper.Plugin wrapper = (aQute.bnd.deployer.repository.wrapper.Plugin) repo;
                wrapper.init();
                name = wrapper.toString();
            } else if (repo instanceof RepositoryPlugin) {
                name = ((RepositoryPlugin) repo).getName();
            } else {
                name = repo.toString();
            }
            repoNameMap.put(name, repo);
        }
        // Create the result list
        orderedRepositories = new ArrayList<>();
        for (String repoName : repoNames.keySet()) {
            Repository repo = repoNameMap.get(repoName);
            if (repo != null)
                orderedRepositories.add(repo);
        }
    }
    Processor repositoryAugments = findRepositoryAugments(orderedRepositories);
    Parameters augments = new Parameters(repositoryAugments.mergeProperties(Constants.AUGMENT), project);
    augments.putAll(new Parameters(properties.mergeProperties(Constants.AUGMENT), project));
    if (!augments.isEmpty()) {
        AggregateRepository aggregate = new AggregateRepository(orderedRepositories);
        AugmentRepository augment = new AugmentRepository(augments, aggregate);
        orderedRepositories = Collections.singleton((Repository) augment);
    }
    for (Repository repository : orderedRepositories) {
        super.addRepository(repository);
    }
    return repositoryAugments;
}
Also used : Parameters(aQute.bnd.header.Parameters) Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) AggregateRepository(aQute.bnd.osgi.repository.AggregateRepository) AggregateRepository(aQute.bnd.osgi.repository.AggregateRepository) Repository(org.osgi.service.repository.Repository) AugmentRepository(aQute.bnd.osgi.repository.AugmentRepository) AugmentRepository(aQute.bnd.osgi.repository.AugmentRepository) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Aggregations

Parameters (aQute.bnd.header.Parameters)1 Processor (aQute.bnd.osgi.Processor)1 AggregateRepository (aQute.bnd.osgi.repository.AggregateRepository)1 AugmentRepository (aQute.bnd.osgi.repository.AugmentRepository)1 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 HashMap (java.util.HashMap)1 Repository (org.osgi.service.repository.Repository)1