Package org.osgi.service.startlevel

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


    {
        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

            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

            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

     */
    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

            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

    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

     */
    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

        ServiceController<?> svc = context.getServiceRegistry(false).getRequiredService(Services.START_LEVEL);

        if (svc == null || svc.getState() != ServiceController.State.UP) {
            context.getFailureDescription().set(OSGiMessages.MESSAGES.osgiSubsystemNotActive());
        } else {
            StartLevel sls = (StartLevel) svc.getValue();
            invokeOperation(sls, context, operation);
        }

        context.completeStep();
    }
View Full Code Here

    void startBundle(final ServiceContainer serviceContainer, ServiceName serviceName, OSGiModule moduleMetaData) {
        if (moduleMetaData.getStartLevel() != null) {
            @SuppressWarnings("unchecked")
            ServiceController<Bundle> controller = (ServiceController<Bundle>) serviceContainer.getRequiredService(serviceName);
            Bundle bundle = controller.getValue();
            StartLevel startLevel = injectedStartLevel.getValue();
            startLevel.setBundleStartLevel(bundle, moduleMetaData.getStartLevel());
            try {
                bundle.start();
            } catch (BundleException ex) {
                ROOT_LOGGER.cannotStart(ex, bundle);
            }
View Full Code Here

TOP

Related Classes of org.osgi.service.startlevel.StartLevel

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.