Examples of StartLevel


Examples of org.osgi.service.startlevel.StartLevel

        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

Examples of org.osgi.service.startlevel.StartLevel

    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

Examples of org.osgi.service.startlevel.StartLevel

          // check that the startlevel allows the bundle to be active (111550)
          if (tracker == null) {
            tracker = new ServiceTracker(context, StartLevel.class.getName(), null);
            tracker.open();
          }
          StartLevel sl = (StartLevel) tracker.getService();
          if (sl != null && (sl.getBundleStartLevel(bundles[i]) <= sl.getStartLevel())) {
            log.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.ERROR, 0, NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE, bundles[i]), 0, null, null));
          }
        }
      }
    } finally {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    }
  }

  private static void installBundles(InitialBundle[] initialBundles, Bundle[] curInitBundles, ArrayList startBundles, ArrayList lazyActivationBundles, List toRefresh) {
    ServiceReference reference = context.getServiceReference(StartLevel.class.getName());
    StartLevel startService = null;
    if (reference != null)
      startService = (StartLevel) context.getService(reference);
    try {
      for (int i = 0; i < initialBundles.length; i++) {
        Bundle osgiBundle = getBundleByLocation(initialBundles[i].locationString, curInitBundles);
        try {
          // don't need to install if it is already installed
          if (osgiBundle == null) {
            InputStream in = initialBundles[i].location.openStream();
            try {
              osgiBundle = context.installBundle(initialBundles[i].locationString, in);
            } catch (BundleException e) {
              StatusException status = e instanceof StatusException ? (StatusException) e : null;
              if (status != null && status.getStatusCode() == StatusException.CODE_OK && status.getStatus() instanceof Bundle) {
                osgiBundle = (Bundle) status.getStatus();
              } else
                throw e;
            }
            // only check for lazy activation header if this is a newly installed bundle and is not marked for persistent start
            if (!initialBundles[i].start && hasLazyActivationPolicy(osgiBundle))
              lazyActivationBundles.add(osgiBundle);
          }
          // always set the startlevel incase it has changed (bug 111549)
          // this is a no-op if the level is the same as previous launch.
          if ((osgiBundle.getState() & Bundle.UNINSTALLED) == 0 && initialBundles[i].level >= 0 && startService != null)
            startService.setBundleStartLevel(osgiBundle, initialBundles[i].level);
          // if this bundle is supposed to be started then add it to the start list
          if (initialBundles[i].start)
            startBundles.add(osgiBundle);
          // include basic bundles in case they were not resolved before
          if ((osgiBundle.getState() & Bundle.INSTALLED) != 0)
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    }
  }

  private static void setStartLevel(final int value) {
    ServiceReference reference = context.getServiceReference(StartLevel.class.getName());
    final StartLevel startLevel = reference != null ? (StartLevel) context.getService(reference) : null;
    if (startLevel == null)
      return;
    final Semaphore semaphore = new Semaphore(0);
    StartupEventListener listener = new StartupEventListener(semaphore, FrameworkEvent.STARTLEVEL_CHANGED);
    context.addFrameworkListener(listener);
    context.addBundleListener(listener);
    startLevel.setStartLevel(value);
    context.ungetService(reference);
    updateSplash(semaphore, listener);
  }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        if (svc == null || svc.getState() != ServiceController.State.UP) {
            // non-metric read-attribute handlers should not fail
            // OSGiMessages.MESSAGES.osgiSubsystemNotActive()
            context.getResult().set(new ModelNode());
        } else {
            StartLevel sls = (StartLevel) svc.getValue();
            invokeOperation(sls, context, operation);
        }

        context.completeStep();
    }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

     * Changes the framework start level and waits for the STARTLEVEL_CHANGED event
     * Note, changing the framework start level is an asynchronous operation.
     */
    public static void changeStartLevel(final BundleContext context, final int level, final long timeout, final TimeUnit units) throws InterruptedException, TimeoutException {
        final ServiceReference sref = context.getServiceReference(StartLevel.class.getName());
        final StartLevel startLevel = (StartLevel) context.getService(sref);
        if (level != startLevel.getStartLevel()) {
            final CountDownLatch latch = new CountDownLatch(1);
            context.addFrameworkListener(new FrameworkListener() {
                public void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED && level == startLevel.getStartLevel()) {
                        latch.countDown();
                    }
                }
            });
            startLevel.setStartLevel(level);
            if (latch.await(timeout, units) == false)
                throw new TimeoutException("Timeout changing start level");
        }
    }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

public class StartLevelHandlerTestCase {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testReadHandler() throws Exception {
        StartLevel sls = Mockito.mock(StartLevel.class);
        Mockito.when(sls.getStartLevel()).thenReturn(999);

        ServiceController sc = Mockito.mock(ServiceController.class);
        Mockito.when(sc.getValue()).thenReturn(sls);
        Mockito.when(sc.getState()).thenReturn(ServiceController.State.UP);
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testWriteHandler() throws Exception {
        StartLevel sls = Mockito.mock(StartLevel.class);

        ServiceController sc = Mockito.mock(ServiceController.class);
        Mockito.when(sc.getValue()).thenReturn(sls);
        Mockito.when(sc.getState()).thenReturn(ServiceController.State.UP);
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    }

    void startBundle(final ServiceContainer serviceContainer, ServiceName serviceName, OSGiCapability moduleMetaData) {
        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
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.