Package org.apache.felix.bundlerepository

Examples of org.apache.felix.bundlerepository.Resource


            if (idx > 0)
            {
                targetName = args[argIdx].substring(0, idx);
                targetVersion = args[argIdx].substring(idx + 1);
            }
            Resource resource = selectNewestVersion(
                searchRepository(ra, targetName, targetVersion));
            if (resource == null)
            {
                System.err.println("Unknown bundle and/or version: " + args[argIdx]);
            }
            else
            {
                String srcURI = (String) resource.getProperties().get(Resource.SOURCE_URI);
                if (srcURI != null)
                {
                    Util.downloadSource(
                        System.out, System.err, new URL(srcURI),
                        localDir, extract);
View Full Code Here


            if (idx > 0)
            {
                targetName = args[argIdx].substring(0, idx);
                targetVersion = args[argIdx].substring(idx + 1);
            }
            Resource resource = selectNewestVersion(
                searchRepository(ra, targetName, targetVersion));
            if (resource == null)
            {
                System.err.println("Unknown bundle and/or version: " + args[argIdx]);
            }
            else
            {
                URL docURL = (URL) resource.getProperties().get("javadoc");
                if (docURL != null)
                {
                    Util.downloadSource(
                        System.out, System.err, docURL, localDir, extract);
                }
View Full Code Here

        attr.putValue("Bundle-License", "http://www.apache.org/licenses/LICENSE-2.0.txt");
        attr.putValue("Bundle-Description", "Utility classes for OSGi.");
        attr.putValue("Import-Package", "org.osgi.framework;version=\"[1.4,2)\"");
        attr.putValue("Bundle-SymbolicName", "org.apache.felix.utils");

        Resource resource = dmh.createResource(attr);

        String xml = dmh.writeResource(resource);
        System.out.println(xml);

        Resource resource2 = dmh.readResource(xml);
        String xml2 = dmh.writeResource(resource2);
        System.out.println(xml2);

        assertEquals(xml, xml2);
    }
View Full Code Here

        // search order of: added, resolving, local and finally remote
        // resources.
        Requirement[] reqs = resource.getRequirements();
        if (reqs != null)
        {
            Resource candidate;
            for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++)
            {
                // Do not resolve optional requirements
                if ((m_resolutionFlags & NO_OPTIONAL_RESOURCES) != 0 && reqs[reqIdx].isOptional())
                {
View Full Code Here

    private Resource searchResources(Requirement req, Set resourceSet)
    {
        for (Iterator iter = resourceSet.iterator(); iter.hasNext(); )
        {
            checkInterrupt();
            Resource resource = (Resource) iter.next();
            Capability[] caps = resource.getCapabilities();
            for (int capIdx = 0; (caps != null) && (capIdx < caps.length); capIdx++)
            {
                if (req.isSatisfied(caps[capIdx]))
                {
                    // The requirement is already satisfied an existing
View Full Code Here

class ResourceComparator implements Comparator
{
    public int compare(Object o1, Object o2)
    {
        Resource r1 = (Resource) o1;
        Resource r2 = (Resource) o2;
        String name1 = r1.getPresentationName();
        String name2 = r2.getPresentationName();
        if (name1 == null)
        {
            if (name2 == null)
            {
                return 0;
View Full Code Here

class ResourceComparator implements Comparator
{
    public int compare(Object o1, Object o2)
    {
        Resource r1 = (Resource) o1;
        Resource r2 = (Resource) o2;
        String name1 = (String) r1.getPresentationName();
        String name2 = (String) r2.getPresentationName();
        if (name1 == null)
        {
            return -1;
        }
        else if (name2 == null)
View Full Code Here

        String bundleId = event.getBundleId();
        try {
            if (isAllowed(event.getSourceGroup(), Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.INBOUND)) {
                Resolver resolver = obrService.resolver();
                String[] target = getTarget(bundleId);
                Resource resource = selectNewestVersion(searchRepository(target[0], target[1]));
                if (resource != null) {
                    resolver.add(resource);
                } else {
                    LOGGER.warn("CELLAR OBR: bundle {} unknown", target[0]);
                }
View Full Code Here

        String bundleId = event.getBundleId();
        try {
            if (isAllowed(event.getSourceGroup(), Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.INBOUND)) {
                Resolver resolver = obrService.resolver();
                String[] target = getTarget(bundleId);
                Resource resource = selectNewestVersion(searchRepository(target[0], target[1]));
                if (resource != null) {
                    resolver.add(resource);
                } else {
                    LOGGER.warn("CELLAR OBR: bundle {} unknown", target[0]);
                }
View Full Code Here

        final org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature("f1", "1.0");
        f.setResolver("obr");
        f.getBundle().add(new Bundle(requirement));
        final RepositoryAdmin admin = createMock(RepositoryAdmin.class);
        final Resolver resolver = createMock(Resolver.class);
        final Resource resource = createMock(Resource.class);
        final ObrResolver obrResolver = new ObrResolver();
        obrResolver.setRepositoryAdmin(admin);

        final Capture<Requirement> captureReq = new Capture<Requirement>();

        expect(admin.getHelper()).andReturn(new DataModelHelperImpl()).anyTimes();
        expect(admin.getSystemRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.getLocalRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.listRepositories()).andReturn(new org.apache.felix.bundlerepository.Repository[0]);
        expect(admin.resolver(EasyMock.<org.apache.felix.bundlerepository.Repository[]>anyObject())).andReturn(resolver);
        resolver.add(EasyMock.capture(captureReq));
        expect(resolver.resolve(Resolver.NO_OPTIONAL_RESOURCES)).andReturn(true);
        expect(resolver.getAddedResources()).andReturn(new Resource[] { });
        expect(resolver.getRequiredResources()).andReturn(new Resource[] { resource });
        expect(resolver.getReason(resource)).andAnswer(new IAnswer<Reason[]>() {
            public Reason[] answer() throws Throwable {
                return new Reason[] { new ReasonImpl( resource, captureReq.getValue()) };
            }
        });
        expect(resource.getURI()).andReturn("foo:bar");
        replay(admin, resolver, resource);

        List<BundleInfo> bundles = obrResolver.resolve(f);
        assertNotNull(bundles);
        assertEquals(1, bundles.size());
View Full Code Here

TOP

Related Classes of org.apache.felix.bundlerepository.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.