Search in sources :

Example 1 with AggregateRepository

use of org.apache.felix.utils.repository.AggregateRepository in project karaf by apache.

the class Activator method getGlobalRepository.

private Repository getGlobalRepository() {
    List<Repository> repositories = new ArrayList<>();
    String[] resourceRepositories = getStringArray("resourceRepositories", "");
    long repositoryExpiration = getLong("repositoryExpiration", FeaturesService.DEFAULT_REPOSITORY_EXPIRATION);
    boolean repositoryIgnoreFailures = getBoolean("repositoryIgnoreFailures", true);
    for (String url : resourceRepositories) {
        url = url.trim();
        if (!url.isEmpty()) {
            if (url.startsWith("json:")) {
                repositories.add(new JsonRepository(url.substring("json:".length()), repositoryExpiration, repositoryIgnoreFailures));
            } else if (url.startsWith("xml:")) {
                repositories.add(new XmlRepository(url.substring("xml:".length()), repositoryExpiration, repositoryIgnoreFailures));
            } else {
                logger.warn("Unrecognized resource repository: " + url);
            }
        }
    }
    Repository globalRepository;
    switch(repositories.size()) {
        case 0:
            globalRepository = null;
            break;
        case 1:
            globalRepository = repositories.get(0);
            break;
        default:
            globalRepository = new AggregateRepository(repositories);
            break;
    }
    return globalRepository;
}
Also used : XmlRepository(org.apache.karaf.features.internal.repository.XmlRepository) XmlRepository(org.apache.karaf.features.internal.repository.XmlRepository) Repository(org.osgi.service.repository.Repository) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository) AggregateRepository(org.apache.felix.utils.repository.AggregateRepository) ArrayList(java.util.ArrayList) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository) AggregateRepository(org.apache.felix.utils.repository.AggregateRepository)

Aggregations

ArrayList (java.util.ArrayList)1 AggregateRepository (org.apache.felix.utils.repository.AggregateRepository)1 JsonRepository (org.apache.karaf.features.internal.repository.JsonRepository)1 XmlRepository (org.apache.karaf.features.internal.repository.XmlRepository)1 Repository (org.osgi.service.repository.Repository)1