Search in sources :

Example 11 with Repository

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");
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Repository(org.osgi.service.repository.Repository) Capability(org.osgi.resource.Capability)

Example 12 with Repository

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");
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Repository(org.osgi.service.repository.Repository) Capability(org.osgi.resource.Capability)

Example 13 with Repository

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()));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Repository(org.osgi.service.repository.Repository) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 14 with Repository

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();
}
Also used : Promise(org.osgi.util.promise.Promise) Repository(org.osgi.service.repository.Repository) WorkspaceR5Repository(bndtools.central.WorkspaceR5Repository) Deferred(org.osgi.util.promise.Deferred) ArrayList(java.util.ArrayList) IMessageManager(org.eclipse.ui.forms.IMessageManager) InvocationTargetException(java.lang.reflect.InvocationTargetException) Success(org.osgi.util.promise.Success)

Example 15 with Repository

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);
}
Also used : Repository(org.osgi.service.repository.Repository) WorkspaceR5Repository(bndtools.central.WorkspaceR5Repository) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

Repository (org.osgi.service.repository.Repository)35 Requirement (org.osgi.resource.Requirement)18 Capability (org.osgi.resource.Capability)16 ArrayList (java.util.ArrayList)11 Collection (java.util.Collection)11 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)9 File (java.io.File)9 Resource (org.osgi.resource.Resource)8 Run (aQute.bnd.build.Run)5 OSGiRepository (aQute.bnd.repository.osgi.OSGiRepository)5 List (java.util.List)5 Resolver (org.osgi.service.resolver.Resolver)5 BndEditModel (aQute.bnd.build.model.BndEditModel)4 ResourcesRepository (aQute.bnd.osgi.repository.ResourcesRepository)4 Processor (aQute.bnd.osgi.Processor)3 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)3 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)3 InfoRepository (aQute.bnd.service.repository.InfoRepository)3 WorkspaceR5Repository (bndtools.central.WorkspaceR5Repository)3 Map (java.util.Map)3