use of org.apache.karaf.features.internal.repository.JsonRepository 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);
}
use of org.apache.karaf.features.internal.repository.JsonRepository 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;
}
Aggregations