Package org.osgi.service.startlevel

Examples of org.osgi.service.startlevel.StartLevel


        try {
            Bundle bundle = visitor.getBundle(bundleIdentifier);
            if (bundle == null) {
                throw new IllegalArgumentException("Bundle ID is wrong: " + bundleIdentifier);
            }
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            return getStartLevel(bundle, startLevel);
        } catch (IllegalArgumentException e) {
View Full Code Here


        try {
            Bundle bundle = visitor.getBundle(bundleIdentifier);
            if (bundle == null) {
                throw new IllegalArgumentException("Wrong Bundle ID: " + bundleIdentifier);
            }
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            return isPersistentlyStarted(bundle, startLevel);
        } catch (IllegalArgumentException e) {
View Full Code Here

        super(FrameworkMBean.class);
    }

    public int getFrameworkStartLevel() throws IOException {
        try {
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            return startLevel.getStartLevel();
        } catch (IOException e) {
            logVisitor.warning("getFrameworkStartLevel error", e);
            throw e;
        } catch (Exception e) {
            logVisitor.warning("getFrameworkStartLevel error", e);
View Full Code Here

        }
    }

    public int getInitialBundleStartLevel() throws IOException {
        try {
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            return startLevel.getInitialBundleStartLevel();
        } catch (IOException e) {
            logVisitor.warning("getInitialBundleStartLevel error", e);
            throw e;
        } catch (Exception e) {
            logVisitor.warning("getInitialBundleStartLevel error", e);
View Full Code Here

        try {
            Bundle bundle = visitor.getBundle(bundleIdentifier);
            if (bundle == null) {
                throw new IllegalArgumentException("Bundle ID is wrong: " + bundleIdentifier);
            }
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            startLevel.setBundleStartLevel(bundle, newLevel);
        } catch (IOException e) {
            logVisitor.warning("setBundleStartLevel error", e);
            throw e;
        } catch (Exception e) {
            logVisitor.warning("setBundleStartLevel error", e);
View Full Code Here

                if (bundleIdentifiers.length != newlevels.length) {
                    throw new IllegalArgumentException("BundlesId array length is not equal to levels array length");
                }
                bundleIds.addAll(Arrays.asList(Utils.toLongArray(bundleIdentifiers)));

                StartLevel startLevel = visitor.getStartLevel();
                if (startLevel == null) {
                    throw new IOException("StartLevel is not available");
                }

                for (int i = 0; bundleIds.size() > 0; i++) {
                    long bundleId = bundleIds.remove(0);
                    try {
                        Bundle bundle = visitor.getBundle(bundleId);
                        if (bundle == null) {
                            throw new IllegalArgumentException("Bundle ID is wrong: " + bundleId);
                        }
                        startLevel.setBundleStartLevel(bundle, newlevels[i]);
                        completedBundles.add(bundleId);
                    } catch (Exception e) {
                        logVisitor.warning("Bundle set start level error", e);
                        isSuccess = false;
                        errorBundleId = bundleId;
View Full Code Here

        }
    }

    public void setFrameworkStartLevel(int level) throws IOException {
        try {
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            startLevel.setStartLevel(level);
        } catch (IOException e) {
            logVisitor.warning("setFrameworkStartLevel error", e);
            throw e;
        } catch (Exception e) {
            logVisitor.warning("setFrameworkStartLevel error", e);
View Full Code Here

        }
    }

    public void setInitialBundleStartLevel(int level) throws IOException {
        try {
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            startLevel.setInitialBundleStartLevel(level);
        } catch (IOException e) {
            logVisitor.warning("setInitialBundleStartLevel error", e);
            throw e;
        } catch (Exception e) {
            logVisitor.warning("setInitialBundleStartLevel error", e);
View Full Code Here

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

    }
  }

  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();
            osgiBundle = context.installBundle(initialBundles[i].locationString, in);
            // 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

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.