use of org.apache.aries.application.management.spi.repository.PlatformRepository in project aries by apache.
the class OBRAriesResolver method getConfiguredObrResolver.
private Resolver getConfiguredObrResolver(String appName, String appVersion, Collection<ModelledResource> byValueBundles, boolean noExtraRepositories) throws ResolverException {
log.debug(LOG_ENTRY, "getConfiguredObrResolver", new Object[] { appName, appVersion, byValueBundles });
DataModelHelper helper = repositoryAdmin.getHelper();
Repository appRepo;
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
RepositoryGeneratorImpl.generateRepository(repositoryAdmin, appName + "_" + appVersion, byValueBundles, bytesOut);
appRepo = helper.readRepository(new InputStreamReader(new ByteArrayInputStream(bytesOut.toByteArray())));
} catch (Exception e) {
throw new ResolverException(e);
}
List<Repository> resolveRepos = new ArrayList<Repository>();
// add system repository
resolveRepos.add(repositoryAdmin.getSystemRepository());
// add application repository
resolveRepos.add(appRepo);
if (!!!noExtraRepositories) {
// add local repository if configured
if (!(excludeLocalRuntime())) {
resolveRepos.add(getLocalRepository(repositoryAdmin));
}
// Need to refresh the repositories added to repository admin
// add user-defined repositories
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository r : repos) {
resolveRepos.add(r);
}
}
Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
addPlatformRepositories(obrResolver, appName, platformRepository);
log.debug(LOG_EXIT, "getConfiguredObrResolver", obrResolver);
return obrResolver;
}
use of org.apache.aries.application.management.spi.repository.PlatformRepository in project aries by apache.
the class OBRAriesResolver method addPlatformRepositories.
/* A 'platform repository' describes capabilities of the target runtime environment
* These should be added to the resolver without being listed as coming from a particular
* repository or bundle.
*/
private void addPlatformRepositories(Resolver obrResolver, String appName, PlatformRepository platformRepository) {
log.debug(LOG_ENTRY, "addPlatformRepositories", new Object[] { obrResolver, appName });
DataModelHelper helper = repositoryAdmin.getHelper();
if (platformRepository != null) {
Collection<URI> uris = platformRepository.getPlatformRepositoryURLs();
if ((uris != null) && (!uris.isEmpty())) {
for (URI uri : uris) {
InputStream is = null;
try {
is = uri.toURL().openStream();
Reader repoReader = new InputStreamReader(is);
Repository aPlatformRepo = helper.readRepository(repoReader);
Resource[] resources = aPlatformRepo.getResources();
for (Resource r : resources) {
Capability[] caps = r.getCapabilities();
for (Capability c : caps) {
obrResolver.addGlobalCapability(c);
}
}
} catch (Exception e) {
// not a big problem
log.error(MessageUtil.getMessage("RESOLVER_UNABLE_TO_READ_REPOSITORY_EXCEPTION", new Object[] { appName, uri }));
} finally {
IOUtils.close(is);
}
}
}
}
log.debug(LOG_EXIT, "addPlatformRepositories");
}
Aggregations