Search in sources :

Example 1 with XmlRepository

use of org.apache.karaf.features.internal.repository.XmlRepository in project karaf by apache.

the class RepositoryManager method getRepository.

public BaseRepository getRepository(String base, String uri) {
    BaseRepository repo;
    if (uri.startsWith("xml:")) {
        String u = URI.create(base).resolve(uri.substring("xml:".length())).toString();
        uri = "xml:" + u;
        repo = new XmlRepository(u, 0, false);
    } else if (uri.startsWith("json:")) {
        String u = URI.create(base).resolve(uri.substring("json:".length())).toString();
        uri = "json:" + u;
        repo = new JsonRepository(u, 0, false);
    } else {
        String u = URI.create(base).resolve(uri).toString();
        uri = "xml:" + u;
        repo = new XmlRepository(u, 0, false);
    }
    repositories.putIfAbsent(uri, repo);
    return repositories.get(uri);
}
Also used : XmlRepository(org.apache.karaf.features.internal.repository.XmlRepository) BaseRepository(org.apache.karaf.features.internal.repository.BaseRepository) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository)

Example 2 with XmlRepository

use of org.apache.karaf.features.internal.repository.XmlRepository 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) AggregateRepository(org.apache.karaf.features.internal.repository.AggregateRepository) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository) ArrayList(java.util.ArrayList) JsonRepository(org.apache.karaf.features.internal.repository.JsonRepository) AggregateRepository(org.apache.karaf.features.internal.repository.AggregateRepository)

Aggregations

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