Examples of adapt()


Examples of org.osgi.framework.Bundle.adapt()

    private RepositoryAdminImpl createRepositoryAdmin() throws Exception
    {
        Bundle sysBundle = Mockito.mock(Bundle.class);
        Mockito.when(sysBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
        BundleRevision br = Mockito.mock(BundleRevision.class);
        Mockito.when(sysBundle.adapt(BundleRevision.class)).thenReturn(br);

        BundleContext bc = Mockito.mock(BundleContext.class);
        Mockito.when(bc.getBundle(0)).thenReturn(sysBundle);
        Mockito.when(sysBundle.getBundleContext()).thenReturn(bc);
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
        EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        final Capture c = new Capture();
        EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
        EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        final Capture c = new Capture();
        EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
        EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        EasyMock.expect(bundleContext.createFilter(null)).andReturn(new Filter() {
            public boolean match(ServiceReference reference) {
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
        EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        final Capture c = new Capture();
        EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

                // bundle JAR file is represented as a revision ordered from
                // newest to oldest. We assume that the first revision found to
                // be exporting the package is the provider of the package,
                // which makes sense since it must have been resolved first.
                List<BundleRevision> originRevisions =
                    bundle.adapt(BundleRevisions.class).getRevisions();
                for (int i = originRevisions.size() - 1; i >= 0; i--)
                {
                    BundleRevision originBr = originRevisions.get(i);
                    List<BundleRevision> revisions = Collections.singletonList(originBr);
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        assertEquals("The Bundle should not directly expose osgi.wiring.package",
                0, bbr.getCapabilities("osgi.wiring.package").size());

        // Check the fragment's capabilities.
        // First check the capabilities on the Bundle Revision, which is available on installed fragments
        BundleRevision fbr = f.adapt(BundleRevision.class);
        List<Capability> fwpCaps = fbr.getCapabilities("osgi.wiring.package");
        assertEquals(1, fwpCaps.size());

        Map<String, Object> expectedFWAttrs = new HashMap<String, Object>();
        expectedFWAttrs.put("osgi.wiring.package", "org.foo.bar");
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

        // Start the bundle. This will make the BundleWiring available on both the bundle and the fragment
        b.start();

        // Check the Bundle Wiring on the fragment. It should only contain the osgi.identity capability
        // All the other capabilities should have migrated to the bundle's BundleWiring.
        BundleWiring fbw = f.adapt(BundleWiring.class);
        List<BundleCapability> fbwCaps = fbw.getCapabilities(null);
        assertEquals("Fragment should only have 1 capability: it's osgi.identity", 1, fbwCaps.size());
        assertCapsEquals(expectedFICap, fbwCaps.get(0));

        // Check the Bundle Wiring on the bundle. It should contain all the capabilities originally on the
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

                + "Export-Package: org.foo.bar;version=\"2.0.0\"\n";
        File feFile = createBundle(femf);

        Bundle fe = felix.getBundleContext().installBundle(feFile.toURI().toASCIIString());

        BundleRevision fbr = fe.adapt(BundleRevision.class);

        List<Capability> feCaps = fbr.getCapabilities("osgi.identity");
        assertEquals(1, feCaps.size());
        Map<String, Object> expectedFEAttrs = new HashMap<String, Object>();
        expectedFEAttrs.put("osgi.identity", "fram.ext");
View Full Code Here

Examples of org.osgi.framework.Bundle.adapt()

            throw new IllegalArgumentException("Not the system bundle: " + sysbundle);

        // Install system module
        try {
            Resource resource = new DefaultResourceBuilder().addIdentityCapability(getSystemIdentity()).getResource();
            BundleWiring wiring = sysbundle.adapt(BundleWiring.class);
            installModule(wiring.getClassLoader(), resource, sysbundle.getHeaders(), null);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.