Package org.osgi.framework

Examples of org.osgi.framework.Bundle


              ix = line.indexOf(" ");
              if (ix!=-1) {
                line = line.substring(0, ix);
              }
              Version version = new Version(line);
              Bundle sysBundle = Activator.getBC().getBundle(0);
              Version sysVersion = new Version((String)sysBundle.getHeaders().get("Bundle-Version"));

              Activator.log.info("sysVersion=" + sysVersion
                                 +", version=" + version);
              if(sysVersion.compareTo(version) < 0) {
                showUpdate(sysVersion, version, notes);
View Full Code Here


      // make alphabetical submenu grouping
      // if number of bundles is large
      buckets = new TreeMap();
      for(Iterator it = bundles.keySet().iterator(); it.hasNext(); ) {
        Object key = it.next();
        Bundle bundle = (Bundle)bundles.get(key);
        String s = Util.getBundleName(bundle);
        String f = s.length() > 0
          ? s.substring(0, 1).toUpperCase()
          : "--";
        Collection bucket = (Collection)buckets.get(f);
        if(bucket == null) {
          bucket = new ArrayList();
          buckets.put(f, bucket);
        }
        bucket.add(bundle);
      }
    } else {
      buckets = new LinkedHashMap();
      for(Iterator it = bundles.keySet().iterator(); it.hasNext(); ) {
        Object key = it.next();
        Bundle bundle = (Bundle)bundles.get(key);

        String f = "#" + bundle.getBundleId() + " " + Util.getBundleName(bundle);
        buckets.put(f, bundle);
      }
    }
    return buckets;
  }
View Full Code Here

      Object val = buckets.get(key);
      if(val instanceof Collection) {
        Collection bucket = (Collection)val;
        JMenu subMenu = new JMenu(key.toString());
        for(Iterator it2 = bucket.iterator(); it2.hasNext(); ) {
          Bundle bundle = (Bundle)it2.next();
          JMenuItem item = makeSelectBundleItem(bundle);
          subMenu.add(item);
        }
        selectMenu.add(subMenu);
      } else if(val instanceof Bundle) {
        Bundle bundle = (Bundle)val;
        JMenuItem item = makeSelectBundleItem(bundle);
        selectMenu.add(item);
      } else {
        throw new RuntimeException("Unknown object=" + val);
      }
View Full Code Here

                        null,
                        options,
                        options[1]);
    if(n == 0) {
      try {
        Bundle sysBundle = Activator.getBC().getBundle((long)0);
        sysBundle.stop();
      } catch (Exception e) {
        showErr("Failed to stop bundle.", e);
      }
    }
  }
View Full Code Here

                                    null,
                                    null,
                                    lastBundleLocation);

      if(lastBundleLocation != null && !"".equals(lastBundleLocation)) {
        Bundle b = Activator.getTargetBC().installBundle(lastBundleLocation);
        Dictionary headers = b.getHeaders();
        if(Util.doAutostart() && Util.canBeStarted(b)) {
          startBundle(b);
        }
      }
    } catch (Exception e) {
View Full Code Here

      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) {
          xargs.append("-initlevel " + level + "\n");
          lastLevel = level;
        }

        xargs.append("-install file:" + name + "\n");

        out.putNextEntry(entry);

        InputStream in = null;
        try {
          in = srcURL.openStream();
          int n = 0;
          while ((n = in.read(buf)) != -1) {
            out.write(buf, 0, n);
          }
        } finally {
          try {
            in.close();
          } catch (Exception ignored) { }
        }
      }

      bid = 0;
      for(Iterator it = all.iterator(); it.hasNext(); ) {
        Bundle b   = (Bundle)it.next();
        bid++;

        if(b.getState() == Bundle.ACTIVE) {
          xargs.append("-start " + bid + "\n");
        }
      }

      if(levelMax != -1) {
View Full Code Here

  public Bundle[] getSelectedBundles() {
    final ArrayList res = new ArrayList(bundleCache.length);

    for(int i = 0; i < bundleCache.length; i++) {
      final Bundle b = bundleCache[i];
      if(isSelected(b)) {
        res.add(b);
      }
    }
    return (Bundle[]) res.toArray(new Bundle[res.size()]);
View Full Code Here

    }.start();
  }

  void stopBundles(Bundle[] bl) {
    for(int i = 0; bl != null && i < bl.length; i++) {
      Bundle b = bl[i];
      stopBundle(b);
    }
  }
View Full Code Here

      stopBundle(b);
    }
  }
  void startBundles(Bundle[] bl) {
    for(int i = 0; bl != null && i < bl.length; i++) {
      Bundle b = bl[i];
      startBundle(b);
    }
  }
View Full Code Here

    }
  }

  void updateBundles(Bundle[] bl) {
    for(int i = 0; bl != null && i < bl.length; i++) {
      Bundle b = bl[i];
      updateBundle(b);
    }
  }
View Full Code Here

TOP

Related Classes of org.osgi.framework.Bundle

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.