use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class GenericResolveContextResolveTest method testResolveRequirementNoDirective.
/**
* Check default directive
*/
public void testResolveRequirementNoDirective() {
Repository repository = createRepo(IO.getFile("testdata/repo6/index.xml"));
GenericResolveContext grc = new GenericResolveContext(logger);
grc.setLevel(2);
grc.addRepository(repository);
Requirement logservice = new CapReqBuilder("osgi.service").addDirective("filter", "(objectClass=org.osgi.service.log.LogService)").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 GenericResolveContextResolveTest method testResolveRequirementActiveDirective.
public void testResolveRequirementActiveDirective() {
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", "active").buildSyntheticRequirement();
List<Capability> providers = grc.findProviders(logservice);
assertEquals(3, providers.size());
assertNames(providers, "test.a", "test.b", "test.c");
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class BndrunResolveContextTest method testSelfCapabilityPreferredOverRepository.
public static void testSelfCapabilityPreferredOverRepository() {
MockRegistry registry = new MockRegistry();
Repository repo = createRepo(IO.getFile("testdata/repo4.index.xml"));
registry.addPlugin(repo);
Requirement resourceReq = new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=dummy-selfcap)").buildSyntheticRequirement();
Resource resource = repo.findProviders(Collections.singleton(resourceReq)).get(resourceReq).iterator().next().getResource();
Requirement packageReq = resource.getRequirements("osgi.wiring.package").get(0);
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers = context.findProviders(packageReq);
assertNotNull(providers);
assertEquals(2, providers.size());
assertEquals(IO.getFile("testdata/repo4/dummy.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
use of org.osgi.service.repository.Repository in project bndtools by bndtools.
the class RepositorySelectionPart method reloadRepos.
private void reloadRepos() {
final IMessageManager messages = getManagedForm().getMessageManager();
messages.removeMessage(MESSAGE_KEY, runReposViewer.getControl());
final List<Repository> allRepos = new ArrayList<>();
try {
allRepos.addAll(repositories.getOrdered());
runReposViewer.setInput(allRepos);
} catch (Exception e) {
messages.addMessage(MESSAGE_KEY, "Repository List: Unable to load OSGi Repositories. " + e.getMessage(), e, IMessageProvider.ERROR, runReposViewer.getControl());
// Load the repos and clear the error message if the Workspace is initialised later.
Central.onWorkspaceInit(new Success<Workspace, Void>() {
@Override
public Promise<Void> call(final Promise<Workspace> resolved) throws Exception {
final Deferred<Void> completion = new Deferred<>();
SWTConcurrencyUtil.execForControl(runReposViewer.getControl(), true, new Runnable() {
@Override
public void run() {
try {
allRepos.clear();
allRepos.addAll(resolved.getValue().getPlugins(Repository.class));
runReposViewer.setInput(allRepos);
messages.removeMessage(MESSAGE_KEY, runReposViewer.getControl());
completion.resolve(null);
} catch (Exception e) {
completion.fail(e);
}
}
});
return completion.getPromise();
}
});
}
updateButtons();
}
use of org.osgi.service.repository.Repository in project bndtools by bndtools.
the class RepositorySelectionPart method updateButtons.
void updateButtons() {
boolean enableDown = false;
boolean enableUp = false;
boolean remove = false;
boolean add = repositories.isStandalone();
IStructuredSelection sel = (IStructuredSelection) runReposViewer.getSelection();
if (!sel.isEmpty()) {
@SuppressWarnings({ "unchecked" }) List<Repository> list = sel.toList();
List<Repository> ordered = repositories.getOrdered();
for (Repository r : list) {
int index = ordered.indexOf(r);
if (index > 0) {
enableUp = true;
}
if (index < ordered.size() - 1) {
enableDown = true;
}
if (repositories.isStandaloneRepository(r)) {
remove = true;
}
}
}
upDownReposPart.setEnabledUp(enableUp);
upDownReposPart.setEnabledDown(enableDown);
addRemove.setRemoveEnabled(remove);
addRemove.setAddEnabled(add);
}
Aggregations