Package org.osgi.framework

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


        BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
        Bundle bundle = EasyMock.createMock(Bundle.class);
        FrameworkStartLevel fsl = EasyMock.createMock(FrameworkStartLevel.class);
        expect(bundleContext.getBundles()).andReturn(new Bundle[0]);
        expect(bundleContext.getBundle()).andReturn(bundle);
        expect(bundle.adapt(FrameworkStartLevel.class)).andReturn(fsl);
        expect(fsl.getInitialBundleStartLevel()).andReturn(50);
        expect(fsl.getStartLevel()).andReturn(100);
        replay(bundleContext, bundle, fsl);

        FeaturesServiceImpl svc = new FeaturesServiceImpl(null, bundleContext, new Storage(), null, null, null, null, null, null, null, null, null);
View Full Code Here


        expect(bundle.getBundleId()).andReturn(id).anyTimes();
        expect(bundle.getSymbolicName()).andReturn(symbolicName).anyTimes();
        expect(bundle.getHeaders()).andReturn(headers).anyTimes();
        BundleStartLevel sl = EasyMock.createMock(BundleStartLevel.class);
        expect(sl.isPersistentlyStarted()).andReturn(true).anyTimes();
        expect(bundle.adapt(BundleStartLevel.class)).andReturn(sl).anyTimes();
        replay(bundle, sl);
        return bundle;
    }
   
    public Dictionary<String, String> headers(String ... keyAndHeader) {
View Full Code Here

        return framework;
    }
   
    public void setBundleStartLevel(long bundleId, int startLevel) {
        Bundle bundle = framework.getBundleContext().getBundle(bundleId);
        BundleStartLevel sl = bundle.adapt(BundleStartLevel.class);
        sl.setStartLevel(startLevel);
    }

    @Override
    public TestContainer start() {
View Full Code Here

        List<Bundle> bundles = new ArrayList<Bundle>();
        for (ProvisionOption<?> bundle : system.getOptions(ProvisionOption.class)) {
            Bundle b = context.installBundle(bundle.getURL());
            bundles.add(b);
            int startLevel = getStartLevel(bundle);
            BundleStartLevel sl = b.adapt(BundleStartLevel.class);
            sl.setStartLevel(startLevel);
            if (bundle.shouldStart()) {
                try {
                    b.start();
                }
View Full Code Here

        expect(ref1.getUsingBundles()).andReturn(new Bundle[]{bundle2, bundle3}).anyTimes();
        expect(ref2.getUsingBundles()).andReturn(new Bundle[]{bundle3}).anyTimes();

        expect(bundle1.adapt(BundleStartLevel.class)).andReturn(bsl).anyTimes();
        expect(bundle2.adapt(BundleStartLevel.class)).andReturn(bsl).anyTimes();
        expect(bundle3.adapt(BundleStartLevel.class)).andReturn(bsl).anyTimes();

        expect(bsl.getStartLevel()).andReturn(80).anyTimes();

        replay(bundle1, bundle2, bundle3, ref1, ref2, bsl);
        return new Bundle[] { bundle1, bundle2, bundle3 };
View Full Code Here

    private void installAndStartBundles(ArtifactResolver resolver, BundleContext context, List<BundleInfo> bundles) {
        for (BundleInfo bundleInfo : bundles) {
            try {
                URI resolvedURI = resolver.resolve(bundleInfo.uri);
                Bundle b = context.installBundle(bundleInfo.uri.toString(), resolvedURI.toURL().openStream());
                b.adapt(BundleStartLevel.class).setStartLevel(bundleInfo.startLevel);
                if (isNotFragment(b)) {
                    b.start();
                }
            } catch (Exception  e) {
                throw new RuntimeException("Error installing bundle listed in " + STARTUP_PROPERTIES_FILE_NAME
View Full Code Here

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will not have an associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identity);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (module == null && wiring != null) {
            try {
                ClassLoader classLoader = wiring.getClassLoader();
                module = runtime.installModule(classLoader, resource, null);
            } catch (ModuleException ex) {
View Full Code Here

                    StartLevelAware startLevelAware = method.getAnnotation(StartLevelAware.class);
                    Bundle bundle = getBundle(testCase);
                    if (bundle != null) {
                        int bundleStartLevel = startLevelAware.startLevel();
                        log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                        BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                        startLevel.setStartLevel(bundleStartLevel);
                        if (startLevelAware.autostart()) {
                            try {
                                bundle.start();
                            } catch (BundleException 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.