Search in sources :

Example 1 with XMLResourceParser

use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.

the class PomRepository method read.

void read() throws Exception {
    if (isStale()) {
        refresh();
    } else {
        try (XMLResourceParser parser = new XMLResourceParser(getLocation())) {
            List<Resource> resources = parser.parse();
            addAll(resources);
        }
    }
}
Also used : Resource(org.osgi.resource.Resource) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser)

Example 2 with XMLResourceParser

use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.

the class SearchRepository method read.

void read() throws Exception {
    if (isStale()) {
        refresh();
    } else {
        try (XMLResourceParser parser = new XMLResourceParser(getLocation())) {
            List<Resource> resources = parser.parse();
            addAll(resources);
        }
    }
}
Also used : Resource(org.osgi.resource.Resource) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser)

Example 3 with XMLResourceParser

use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.

the class PomRepositoryTest method testRepository.

public void testRepository() throws Exception {
    MavenRepository repo = getRepo();
    Revision revision = Revision.valueOf("bcel:bcel:5.1");
    PomRepository pom = new PomRepository(repo, client, location).revisions(Collections.singleton(revision));
    assertTrue(location.isFile());
    try (XMLResourceParser xp = new XMLResourceParser(location)) {
        List<Resource> parse = xp.parse();
        assertEquals(parse.size(), pom.getResources().size());
    }
}
Also used : MavenRepository(aQute.maven.provider.MavenRepository) Revision(aQute.maven.api.Revision) Resource(org.osgi.resource.Resource) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser)

Example 4 with XMLResourceParser

use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.

the class RepositoryTest method testXMLParserSmall.

public void testXMLParserSmall() throws Exception {
    URL url = RepositoryTest.class.getResource("repoindex-file.xml");
    try (XMLResourceParser xrp = new XMLResourceParser(url.toURI())) {
        xrp.setTrace(true);
        List<Resource> resources = xrp.parse();
        assertTrue(xrp.check());
        assertNotNull(resources);
        assertEquals(21, resources.size());
        Requirement requirement = new RequirementBuilder("osgi.extender").addDirective("filter", "(osgi.extender=osgi.component)").buildSyntheticRequirement();
        Map<Requirement, Collection<Capability>> caps = getResourcesRepository(resources).findProviders(Collections.singleton(requirement));
        assertEquals(1, caps.get(requirement).size());
        Resource res = caps.get(requirement).iterator().next().getResource();
        assertEquals("org.apache.felix.scr", ResourceUtils.getIdentityCapability(res).getAttributes().get("osgi.identity"));
        String location = ResourceUtils.getContentCapability(res).getAttributes().get("url").toString();
        assertFalse(location, location.contains("file:"));
    }
}
Also used : Requirement(org.osgi.resource.Requirement) Resource(org.osgi.resource.Resource) Collection(java.util.Collection) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser) URL(java.net.URL) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Example 5 with XMLResourceParser

use of aQute.bnd.osgi.repository.XMLResourceParser in project bnd by bndtools.

the class RepositoryTest method testXMLParserLarge.

public void testXMLParserLarge() throws Exception {
    URL url = RepositoryTest.class.getResource("larger-repo.xml");
    try (XMLResourceParser xrp = new XMLResourceParser(url.toURI())) {
        xrp.setTrace(true);
        List<Resource> resources = xrp.parse();
        assertTrue(xrp.check());
        assertNotNull(resources);
        assertEquals(61, resources.size());
        Requirement requirement = new RequirementBuilder("osgi.extender").addDirective("filter", "(osgi.extender=osgi.component)").buildSyntheticRequirement();
        Map<Requirement, Collection<Capability>> caps = getResourcesRepository(resources).findProviders(Collections.singleton(requirement));
        assertEquals(1, caps.get(requirement).size());
        Resource res = caps.get(requirement).iterator().next().getResource();
        assertEquals("org.apache.felix.scr", ResourceUtils.getIdentityCapability(res).getAttributes().get("osgi.identity"));
        String location = ResourceUtils.getContentCapability(res).getAttributes().get("url").toString();
        String base = url.toURI().toString();
        assertFalse(location, location.startsWith(base));
    }
}
Also used : Requirement(org.osgi.resource.Requirement) Resource(org.osgi.resource.Resource) Collection(java.util.Collection) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser) URL(java.net.URL) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Aggregations

XMLResourceParser (aQute.bnd.osgi.repository.XMLResourceParser)5 Resource (org.osgi.resource.Resource)5 RequirementBuilder (aQute.bnd.osgi.resource.RequirementBuilder)2 URL (java.net.URL)2 Collection (java.util.Collection)2 Requirement (org.osgi.resource.Requirement)2 Revision (aQute.maven.api.Revision)1 MavenRepository (aQute.maven.provider.MavenRepository)1