Examples of StartLevel


Examples of org.osgi.service.startlevel.StartLevel

          add(itemUpdateBundles = new JMenuItem(actionUpdateBundles));
          add(itemUninstallBundles = new JMenuItem(actionUninstallBundles));
          add(itemResolveBundles   = new JMenuItem(actionResolveBundles));
          add(itemRefreshBundles   = new JMenuItem(actionRefreshBundles));

          StartLevel sls = (StartLevel)slTracker.getService();
          if(sls != null) {
            add(startLevelMenu = makeStartLevelMenu());
          }
        }
      };
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

            final AbstractButton jrb = new JRadioButtonMenuItem(Integer.toString(i));
            group.add(jrb);
            add(jrb);
            jrb.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ev) {
                  final StartLevel sls = (StartLevel)slTracker.getService();

                  final Bundle[] bl = getSelectedBundles();

                  if(null != sls) {
                    final int level = Integer.parseInt(jrb.getText());
                    for (int i=0; i<bl.length; i++) {
                      sls.setBundleStartLevel(bl[i], level);
                    }
                    updateBundleViewSelections();
                  }
                }
              });
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

    // remove system bundle.
    all.remove(Activator.getTargetBC().getBundle(0));

    ZipOutputStream out = null;

    StartLevel sl = (StartLevel)slTracker.getService();

    File jarunpackerFile = new File("../tools/jarunpacker/out/jarunpacker/jarunpacker.jar");

    URL jarunpackerURL = null;

    try {
      jarunpackerURL = getClass().getResource("/jarunpacker.jar");
    } catch (Exception ignored) {
    }

    InputStream jarunpacker_in = null;

    try {
      if(file.getName().endsWith(".jar")) {


        if(jarunpackerURL != null) {
          jarunpacker_in = jarunpackerURL.openStream();
        } else if(jarunpackerFile.exists()) {
          jarunpacker_in = new FileInputStream(jarunpackerFile);
        }

        if(jarunpacker_in != null) {
          // Construct a string version of a manifest
          StringBuffer sb = new StringBuffer();
          sb.append("Manifest-Version: 1.0\n");
          sb.append("Main-class: org.knopflerfish.tools.jarunpacker.Main\n");
          sb.append("jarunpacker-optbutton: base\n");
          sb.append("jarunpacker-destdir: .\n");
          sb.append("knopflerfish-version: " + base + "\n");
          sb.append("jarunpacker-opendir: " + base + "\n");

          // Convert the string to a input stream
          InputStream is = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
          Manifest mf = new Manifest(is);

          out = new JarOutputStream(new FileOutputStream(file), mf);
        } else {
          out = new JarOutputStream(new FileOutputStream(file));
        }
      } else if(file.getName().endsWith(".zip")) {
        out = new ZipOutputStream(new FileOutputStream(file));
      }

      StringBuffer xargs = new StringBuffer();

      int levelMax = -1;

      int bid = 0;
      int lastLevel = -1;
      for(Iterator it = all.iterator(); it.hasNext(); ) {
        Bundle b   = (Bundle)it.next();
        String loc = b.getLocation();

        bid++;

        URL srcURL = new URL(loc);

        String name = Util.shortLocation(loc);

        ZipEntry entry = new ZipEntry(base + "/" + name);

        int level     = -1;

        try {
          level = sl.getBundleStartLevel(b);
        } catch (Exception ignored) {        }

        levelMax = Math.max(level, levelMax);

        if(level != -1 && level != lastLevel) {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

      if (b.getSymbolicName() != null) {
        appendRow(sb, "Symbolic name", b.getSymbolicName());
      }
      appendRow(sb, "Last modified", "" + new SimpleDateFormat().format(new Date(b.getLastModified())));

      StartLevel sls = (StartLevel)Activator.desktop.slTracker.getService();
      if(sls != null) {
        String level = "";
        try {
          level = Integer.toString(sls.getBundleStartLevel(b));
        } catch (IllegalArgumentException e) {
          level = "not managed";
        }
        appendRow(sb, "Start level", level);
      }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        try {
          is = new FileInputStream(file);
          bundle = Activator.bc.installBundle(location, is);

          // Set bundle start level if possible
          StartLevel sl = (StartLevel)
            Activator.startLevelTracker.getService();
          sl.setBundleStartLevel(bundle, config.startLevel);

          log("installed " + this);
        } catch (Exception ioe) {
          log("Failed to install " + this +"; "+ioe, ioe);
        } finally {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

      }
    }
    if (-1==startLevel) {
      // Ask the start level service for the default start level of
      // bundles
      StartLevel sl = (StartLevel) Activator.startLevelTracker.getService();
      if (null!=sl) {
        startLevel = sl.getInitialBundleStartLevel();
      } else {
        startLevel = 1; // Fallback to the default initial bundle start level
      }
    }
    props.put(PROP_STARTLEVEL, new Integer(startLevel));
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

     * @return true if the bundle has start level minor than 50
     */
    public static boolean isASystemBundle(BundleContext bundleContext, Bundle bundle) {
        ServiceReference ref = bundleContext.getServiceReference(StartLevel.class.getName());
        if (ref != null) {
            StartLevel sl = (StartLevel) bundleContext.getService(ref);
            if (sl != null) {
                int level = sl.getBundleStartLevel(bundle);
                int sbsl = 49;
                final String sbslProp = bundleContext.getProperty( "karaf.systemBundlesStartLevel" );
                if (sbslProp != null) {
                    try {
                       sbsl = Integer.valueOf( sbslProp );
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        this.bundleStateListenerFactories = bundleStateListenerFactories;
    }

    protected Object doExecute() throws Exception {
        ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
        StartLevel sl = null;
        if (ref != null) {
            sl = (StartLevel) getBundleContext().getService(ref);
        }
        if (sl == null) {
            System.out.println("StartLevel service is unavailable.");
        }

        ServiceReference pkgref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
        PackageAdmin admin = null;
        if (pkgref != null) {
            admin = (PackageAdmin) getBundleContext().getService(pkgref);
            if (admin == null) {
                System.out.println("PackageAdmin service is unavailable.");
            }
        }

        Bundle[] bundles = getBundleContext().getBundles();
        if (bundles != null) {
            // Determine threshold
            final String sbslProp = bundleContext.getProperty("karaf.systemBundlesStartLevel");
            if (sbslProp != null) {
                try {
                   if (bundleLevelThreshold < 0) {
                       bundleLevelThreshold = Integer.valueOf( sbslProp );
                   }
                }
                catch( Exception ignore ) {
                   // ignore
                }
            }
            // Display active start level.
            if (sl != null) {
                System.out.println("START LEVEL " + sl.getStartLevel() +
                                   " , List Threshold: " + bundleLevelThreshold);
            }

            // Print column headers.
            String msg = " Name";
            if (showLoc) {
               msg = " Location";
            }
            else if (showSymbolic) {
               msg = " Symbolic name";
            }
            else if (showUpdate) {
               msg = " Update location";
            }
            String level = (sl == null) ? "" : "  Level ";
            String headers = "   ID   State       ";
            for (BundleStateListener.Factory factory : bundleStateListenerFactories) {
                BundleStateListener listener = factory.getListener();
                if (listener != null) {
                    headers += "  " + listener.getName() + " ";
                }
            }
            headers += level + msg;
            System.out.println(headers);
            for (int i = 0; i < bundles.length; i++) {
              if (sl.getBundleStartLevel(bundles[i]) >= bundleLevelThreshold) {
                  // Get the bundle name or location.
                  String name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_NAME);
                  // If there is no name, then default to symbolic name.
                  name = (name == null) ? bundles[i].getSymbolicName() : name;
                  // If there is no symbolic name, resort to location.
                  name = (name == null) ? bundles[i].getLocation() : name;
 
                  // Overwrite the default value is the user specifically
                  // requested to display one or the other.
                  if (showLoc) {
                      name = bundles[i].getLocation();
                  }
                  else if (showSymbolic) {
                      name = bundles[i].getSymbolicName();
                      name = (name == null) ? "<no symbolic name>" : name;
                  }
                  else if (showUpdate) {
                      name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
                      name = (name == null) ? bundles[i].getLocation() : name;
                  }
                  // Show bundle version if not showing location.
                  String version = (String) bundles[i].getHeaders().get(Constants.BUNDLE_VERSION);
                  name = (!showLoc && !showUpdate && (version != null)) ? name + " (" + version + ")" : name;
                  long l = bundles[i].getBundleId();
                  String id = String.valueOf(l);
                  if (sl == null) {
                      level = "1";
                  }
                  else {
                      level = String.valueOf(sl.getBundleStartLevel(bundles[i]));
                  }
                  while (level.length() < 5) {
                      level = " " + level;
                  }
                  while (id.length() < 4) {
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
        if (ref == null) {
            System.out.println("StartLevel service is unavailable.");
            return;
        }
        StartLevel sl = getService(StartLevel.class, ref);
        if (sl == null) {
            System.out.println("StartLevel service is unavailable.");
            return;
        }

        if (level == null) {
            System.out.println("Level " + sl.getBundleStartLevel(bundle));
        }
        else if ((level < 50) && sl.getBundleStartLevel(bundle) > 50){
            for (;;) {
                StringBuffer sb = new StringBuffer();
                System.err.println("You are about to designate bundle as a system bundle.  Do you want 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)) {
                    sl.setBundleStartLevel(bundle, level);
                    break;
                } else if ("no".equals(str)) {
                    break;
                }
            }
        } else {
            sl.setBundleStartLevel(bundle, level);
        }
    }
View Full Code Here

Examples of org.osgi.service.startlevel.StartLevel

        // Check if we want to convert URLs to maven style
        boolean convertToMavenUrls = Boolean.parseBoolean(configProps.getProperty(PROPERTY_CONVERT_TO_MAVEN_URL, "true"));

        // Retrieve the Start Level service, since it will be needed
        // to set the start level of the installed bundles.
        StartLevel sl = (StartLevel) context.getService(
                context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName()));

        // Set the default bundle start level
        int ibsl = 60;
        try {
            String str = configProps.getProperty("karaf.startlevel.bundle");
            if (str != null) {
                ibsl = Integer.parseInt(str);
            }
        } catch (Throwable t) {
        }
        sl.setInitialBundleStartLevel(ibsl);

        // The auto-install property specifies a space-delimited list of
        // bundle URLs to be automatically installed into each new profile;
        // the start level to which the bundles are assigned is specified by
        // appending a ".n" to the auto-install property name, where "n" is
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.