use of org.osgi.service.repository.Repository 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;
}
use of org.osgi.service.repository.Repository in project karaf by apache.
the class Activator method doStart.
protected void doStart() throws Exception {
BundleContext systemBundleContext = bundleContext.getBundle(0).getBundleContext();
ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
Resolver resolver = new ResolverImpl(new Slf4jResolverLog(LoggerFactory.getLogger(ResolverImpl.class)));
URLStreamHandlerService mvnUrlHandler = getTrackedService(URLStreamHandlerService.class);
if (configurationAdmin == null || mvnUrlHandler == null) {
return;
}
StandardRegionDigraph dg = DigraphHelper.loadDigraph(bundleContext);
registerRegionDiGraph(dg);
boolean configCfgStore = getBoolean("configCfgStore", FeaturesService.DEFAULT_CONFIG_CFG_STORE);
FeatureConfigInstaller configInstaller = configurationAdmin != null ? new FeatureConfigInstaller(configurationAdmin, configCfgStore) : null;
installSupport = new BundleInstallSupportImpl(bundleContext.getBundle(), bundleContext, systemBundleContext, configInstaller, dg);
register(RegionDigraphPersistence.class, () -> installSupport.saveState());
FeatureRepoFinder featureFinder = new FeatureRepoFinder();
register(ManagedService.class, featureFinder, FeatureRepoFinder.getServiceProperties());
Repository globalRepository = getGlobalRepository();
FeaturesServiceConfig cfg = getConfig();
StateStorage stateStorage = createStateStorage();
featuresService = new FeaturesServiceImpl(stateStorage, featureFinder, configurationAdmin, resolver, installSupport, globalRepository, cfg);
try {
EventAdminListener eventAdminListener = new EventAdminListener(bundleContext);
featuresService.registerListener(eventAdminListener);
} catch (Throwable t) {
// No EventAdmin support in this case
}
register(FeaturesService.class, featuresService);
featuresListenerTracker = createFeatureListenerTracker();
featuresListenerTracker.open();
FeaturesServiceMBeanImpl featuresServiceMBean = new FeaturesServiceMBeanImpl();
featuresServiceMBean.setBundleContext(bundleContext);
featuresServiceMBean.setFeaturesService(featuresService);
registerMBean(featuresServiceMBean, "type=feature");
String[] featuresRepositories = getStringArray("featuresRepositories", "");
String featuresBoot = getString("featuresBoot", "");
boolean featuresBootAsynchronous = getBoolean("featuresBootAsynchronous", false);
BootFeaturesInstaller bootFeaturesInstaller = new BootFeaturesInstaller(bundleContext, featuresService, featuresRepositories, featuresBoot, featuresBootAsynchronous);
bootFeaturesInstaller.start();
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class AggregateRepository method findProviders.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
MultiMap<Requirement, Capability> result = new MultiMap<>();
for (Repository repository : repositories) {
Map<Requirement, Collection<Capability>> capabilities = repository.findProviders(requirements);
result.addAll(capabilities);
}
return (Map) result;
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class GenericResolveContextResolveTest method testResolveRequirementResolveDirective.
/**
* Check expressly set directive
*/
public void testResolveRequirementResolveDirective() {
Repository repository = createRepo(IO.getFile("testdata/repo6/index.xml"));
GenericResolveContext grc = new GenericResolveContext(logger);
grc.addRepository(repository);
Requirement logservice = new CapReqBuilder("osgi.service").addDirective("filter", "(objectClass=org.osgi.service.log.LogService)").addDirective("effective", "resolve").buildSyntheticRequirement();
List<Capability> providers = grc.findProviders(logservice);
assertEquals(2, providers.size());
assertNames(providers, "test.a", "test.b");
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class P2Indexer method refresh.
public void refresh() throws Exception {
Repository repository = readRepository();
save(repository);
this.bridge = new BridgeRepository(repository);
}
Aggregations