Examples of StartLevel


Examples of org.osgi.service.startlevel.StartLevel

    {
        Bundle bundle = bundleContext.installBundle( location, bundleStream );

        if ( startlevel > 0 )
        {
            StartLevel sl = ( StartLevel ) getService( StartLevel.class.getName() );
            if ( sl != null )
            {
                sl.setBundleStartLevel( bundle, startlevel );
            }
        }

        if ( doStart )
        {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        {
            out.println("StartLevel service is unavailable.");
            return;
        }

        StartLevel sl = (StartLevel) m_context.getService(ref);
        if (sl == null)
        {
            out.println("StartLevel service is unavailable.");
            return;
        }

        // Parse command line.
        StringTokenizer st = new StringTokenizer(s, " ");

        // Ignore the command name.
        st.nextToken();

        if (st.countTokens() == 0)
        {
            out.println("Level " + sl.getStartLevel());
        }
        else if (st.countTokens() >= 1)
        {
            String levelStr = st.nextToken().trim();

            try {
                int level = Integer.parseInt(levelStr);
                sl.setStartLevel(level);
            } catch (NumberFormatException ex) {
                err.println("Unable to parse integer '" + levelStr + "'.");
            } catch (Exception ex) {
                err.println(ex.toString());
            }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    public void execute(String s, PrintStream out, PrintStream err)
    {
        // Get start level service.
        ServiceReference ref = m_context.getServiceReference(
            org.osgi.service.startlevel.StartLevel.class.getName());
        StartLevel sl = null;
        if (ref != null)
        {
            sl = (StartLevel) m_context.getService(ref);
        }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    {
        final String action = request.getParameter( "action"); //$NON-NLS-1$

        if ( "setStartLevel".equals( action )) //$NON-NLS-1$
        {
            StartLevel sl = getStartLevel();
            if ( sl != null )
            {
                int bundleSL = WebConsoleUtil.getParameterInt( request, "bundleStartLevel", -1 );
                if ( bundleSL > 0 && bundleSL != sl.getInitialBundleStartLevel() )
                {
                    sl.setInitialBundleStartLevel( bundleSL );
                }

                int systemSL = WebConsoleUtil.getParameterInt( request, "systemStartLevel", -1 );
                if ( systemSL > 0 && systemSL != sl.getStartLevel() )
                {
                    sl.setStartLevel( systemSL );
                }
            }
        }
        else if ( "gc".equals( action ) ) //$NON-NLS-1$
        {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

            final Map<String, Bundle> currentBundles,
            final List<Bundle> installed) {

        // get the start level service (if possible) so we can set the initial start level
        ServiceReference ref = bundleContext.getServiceReference(StartLevel.class.getName());
        StartLevel startLevelService = (ref != null)
                ? (StartLevel) bundleContext.getService(ref)
                : null;

        boolean requireRestart = false;
        try {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

            final Bundle b = this.getBundleContext().installBundle(getResource().getURL(), getResource().getInputStream());
            ctx.log("Installed bundle {} from resource {}", b, getResource());
            // optionally set the start level
            if ( startLevel > 0 ) {
                // get the start level service (if possible) so we can set the initial start level
                final StartLevel startLevelService = this.getStartLevel();
                if (startLevelService != null) {
                    startLevelService.setBundleStartLevel(b, startLevel);
                    ctx.log("Set start level for bundle {} to {}", b, startLevel);
                } else {
                    this.getLogger().info("Ignoring start level {} for bundle {} - start level service not available.",
                            startLevel, b);
                }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

     */
    private boolean isBundleActive(final Bundle b) {
        if ( BundleUtil.isBundleActive(b) ) {
            return true;
        }
        final StartLevel startLevelService = this.getStartLevel();
        return startLevelService.isBundlePersistentlyStarted(b);
    }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

            b.update(getResource().getInputStream());
            ctx.log("Updated bundle {} from resource {}", b, getResource());

            // start level handling - after update to avoid starting the bundle
            // just before the update
            final StartLevel startLevelService = this.getStartLevel();
            if ( startLevelService != null ) {
                final int newStartLevel = this.getBundleStartLevel();
                final int oldStartLevel = startLevelService.getBundleStartLevel(b);
                if ( newStartLevel != oldStartLevel && newStartLevel != 0 ) {
                    startLevelService.setBundleStartLevel(b, newStartLevel);
                    ctx.log("Set start level for bundle {} to {}", b, newStartLevel);
                }
            }

            if (reactivate) {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    public void testToCompositeData() throws Exception {
       
        Bundle bundle = mock(Bundle.class);
        BundleContext context = mock(BundleContext.class);
        PackageAdmin packageAdmin = mock(PackageAdmin.class);
        StartLevel startLevel = mock(StartLevel.class);
       
        Bundle b1 = mock(Bundle.class);
        when(b1.getSymbolicName()).thenReturn("b1");
        when(b1.getBundleId()).thenReturn(new Long(44));
        Bundle b2 = mock(Bundle.class);
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

     */
    private void startBundles(BundleContext context, List<Bundle> bundles) {

        // the start level service to set the initial start level
        ServiceReference ref = context.getServiceReference(StartLevel.class.getName());
        StartLevel startLevel = (ref != null)
                ? (StartLevel) context.getService(ref)
                : null;

        // start all bundles
        for (Bundle bundle : bundles) {

            if (startLevel != null) {
                startLevel.setBundleStartLevel(bundle, 1);
            }

            try {
                bundle.start();
            } catch (BundleException be) {
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.