Package org.osgi.framework.startlevel

Examples of org.osgi.framework.startlevel.BundleStartLevel


    @Reference
    Session session;

    protected Object doExecute(Bundle bundle) throws Exception {
        // Get package instance service.
        BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
        if (level == null) {
            System.out.println("Level " + bsl.getStartLevel());
        }
        else {
            int sbsl = bundleService.getSystemBundleThreshold();
            if ((level < sbsl) && (bsl.getStartLevel() >= sbsl)) {
                if (!JaasHelper.currentUserHasRole(BundleService.SYSTEM_BUNDLES_ROLE)) {
                    throw new IllegalArgumentException("Insufficient priviledges");
                }

            }
            bsl.setStartLevel(level);
        }
        return null;
    }
View Full Code Here


        expect(bundle.compareTo(EasyMock.<Bundle>anyObject())).andReturn(1).anyTimes();

        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;
    }
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);
    }
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();
                }
                catch (BundleException e) {
View Full Code Here

    private Bundle[] createBundles() {
        Bundle bundle1 = createBundle(1, "Bundle A");
        Bundle bundle2 = createBundle(2, "Bundle B");
        Bundle bundle3 = createBundle(3, "Bundle C");

        BundleStartLevel bsl = createMock(BundleStartLevel.class);

        ServiceReference<?> ref1 = createServiceRef(Constants.OBJECTCLASS, new String[]{"org.example.MyService"},
            "key1", "value1");
        ServiceReference<?> ref2 = createServiceRef(Constants.OBJECTCLASS, new String[]{"org.example.OtherService"}, "key2", 1);

        addRegisteredServices(bundle1, ref1, ref2);
        addRegisteredServices(bundle2, ref2);
        expect(bundle3.getRegisteredServices()).andReturn(null).anyTimes();

        expect(bundle1.getServicesInUse()).andReturn(null).anyTimes();
        addUsedServices(bundle2, ref1);
        addUsedServices(bundle3, ref1, ref2);
       
        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

                    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) {
                                log.log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

TOP

Related Classes of org.osgi.framework.startlevel.BundleStartLevel

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.