Package org.osgi.framework.startlevel

Examples of org.osgi.framework.startlevel.BundleStartLevel


        bundleStateMap.put(Bundle.STARTING, BundleState.Starting);
        bundleStateMap.put(Bundle.STOPPING, BundleState.Stopping);
    };

    public BundleInfoImpl(Bundle bundle, BundleState extState) {
        BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
        this.startLevel = bsl.getStartLevel();
        this.name = (String)bundle.getHeaders().get(Constants.BUNDLE_NAME);
        this.symbolicName = bundle.getSymbolicName();
        String locationFromHeader = (String)bundle.getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
        this.updateLocation = locationFromHeader != null ? locationFromHeader : bundle.getLocation();
        this.version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
View Full Code Here


        try {
            final Bundle b = ctx.installBundle(bundleRef, url.openStream());
           
            final int level = getStartLevel(crankstartContext);
            if(level > 0) {
                final BundleStartLevel bsl = (BundleStartLevel)b.adapt(BundleStartLevel.class);
                if(bsl == null) {
                    log.warn("Bundle does not adapt to BundleStartLevel, cannot set start level", bundleRef);
                }
                bsl.setStartLevel(level);
            }
           
            log.info("bundle installed at start level {}: {}", level, bundleRef);
        } finally {
            bundleStream.close();
View Full Code Here

    public <A> A adapt(Class<A> type)
    {
        if (type == BundleStartLevel.class)
        {
            return (A) new BundleStartLevel() {

                public Bundle getBundle()
                {
                    return PojoSRBundle.this;
                }
View Full Code Here

    @Argument(index = 1, name = "startLevel", description = "The bundle's new start level", required = false, multiValued = false)
    Integer level;

    protected void doExecute(Bundle bundle) throws Exception {
        // Get package instance service.
        BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
        if (bsl == null) {
            System.out.println("StartLevel service is unavailable.");
            return;
        }
        if (level == null) {
            System.out.println("Level " + bsl.getStartLevel());
        }
        else if ((level < 50) && (bsl.getStartLevel() > 50) && !force){
            for (;;) {
                ConsoleReader reader = (ConsoleReader) session.get(".jline.reader");
                String msg = "You are about to designate bundle as a system bundle.  Do you wish to continue (yes/no): ";
                String str = reader.readLine(msg);
                if ("yes".equalsIgnoreCase(str)) {
                    bsl.setStartLevel(level);
                    break;
                } else if ("no".equalsIgnoreCase(str)) {
                    break;
                }
            }

        } else {
            bsl.setStartLevel(level);
        }
    }
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

                Deployment andep = method.getAnnotation(Deployment.class);
                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    int bundleStartLevel = method.getAnnotation(StartLevelAware.class).startLevel();
                    Bundle bundle = getBundle(testCase);
                    log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                    BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                    startLevel.setStartLevel(bundleStartLevel);
                }
            }
        }
    }
View Full Code Here

    @Argument(index = 1, name = "startLevel", description = "The bundle's new start level", required = false, multiValued = false)
    Integer level;

    protected void doExecute(Bundle bundle) throws Exception {
        // Get package instance service.
        BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
        if (bsl == null) {
            System.out.println("StartLevel service is unavailable.");
            return;
        }
        if (level == null) {
            System.out.println("Level " + bsl.getStartLevel());
        }
        else if ((level < 50) && bsl.getStartLevel() > 50){
            for (;;) {
                StringBuffer sb = new StringBuffer();
                System.err.println("You are about to designate bundle as a system bundle.  Do you wish to continue (yes/no): ");
                System.err.flush();
                for (;;) {
                    int c = System.in.read();
                    if (c < 0) {
                        return;
                    }
                    System.err.println((char) c);
                    if (c == '\r' || c == '\n') {
                        break;
                    }
                    sb.append((char) c);
                }
                String str = sb.toString();
                if ("yes".equals(str)) {
                    bsl.setStartLevel(level);
                    break;
                } else if ("no".equals(str)) {
                    break;
                }
            }
        } else {
            bsl.setStartLevel(level);
        }
    }
View Full Code Here

        assertEquals("Initial bundle start level", 1, initialStartLevel);

        assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());
        assertEquals("start-level-bundle", bundle.getSymbolicName());

        BundleStartLevel bStartLevel = bundle.adapt(BundleStartLevel.class);
        int bundleStartLevel = bStartLevel.getStartLevel();
        assertEquals("Bundle start level", 3, bundleStartLevel);

        try {
            bundle.start(Bundle.START_TRANSIENT);
            fail("Bundle cannot be started due to the Framework's current start level");
View Full Code Here

                Deployment andep = method.getAnnotation(Deployment.class);
                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    int bundleStartLevel = method.getAnnotation(StartLevelAware.class).startLevel();
                    Bundle bundle = getBundle(testCase);
                    log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                    BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                    startLevel.setStartLevel(bundleStartLevel);
                }
            }
        }
    }
View Full Code Here

                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    StartLevelAware startLevelAware = method.getAnnotation(StartLevelAware.class);
                    int bundleStartLevel = startLevelAware.startLevel();
                    Bundle bundle = getBundle(testCase);
                    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.