Package org.osgi.framework

Examples of org.osgi.framework.Bundle


      if(bundles.size() == 0) {
        return true;
      }

      for(Iterator it = bundles.iterator(); it.hasNext();) {
        Bundle b = (Bundle)it.next();
        if((Util.getBundle(e) != null) &&
           (b.getBundleId() == Util.getBundle(e).getBundleId())) {
          return true;
        }
      }

      return false;
View Full Code Here


      return 1;
    }

    String bname = (String) opts.get("bundle");
    Bundle[] bl = getBundles(new String[] { bname }, true);
    Bundle bundle = bl[0];
    if (bundle == null) {
      out.println("ERROR! No matching bundle for '" + bname + "'");
      return 1;
    }

    bl = getBundles(null, false, false, false);

    // Package

    Vector pkgClosure = new Vector();
    // This is O(n2) at least, possibly O(n3). Should be improved
    for(int b = 0; b < bl.length; b++) {
      ExportedPackage[] pkgs = packageAdmin.getExportedPackages(bl[b]);
      if (pkgs == null) continue;
      for(int p = 0; p < pkgs.length; p++) {
        Bundle[] bl2 = pkgs[p].getImportingBundles();
        if (bl2 == null) continue;
        for(int ib = 0; ib < bl2.length;  ib++) {
          if(bl2[ib].getBundleId() == bundle.getBundleId() && !pkgClosure.contains(bl[b])) {
            pkgClosure.add(bl[b]);
          }
        }
      }
    }
    pkgClosure.remove(bundle);
    if (pkgClosure.size() == 0) {
      out.println("No package dependencies");
    } else {
      out.println("Static dependencies via packages:");
      Bundle[] bundles = (Bundle[]) pkgClosure.toArray(new Bundle[pkgClosure.size()]);
      printBundles(out, bundles, false, true);
    }

    // Service

    Vector serviceClosure = new Vector();
    ServiceReference[] srl = bundle.getServicesInUse();
    for (int i = 0; srl != null && i < srl.length; i++) {
      if (!serviceClosure.contains(srl[i].getBundle())) {
        serviceClosure.add(srl[i].getBundle());
      }
    }
View Full Code Here

    String[] loc = (String[]) opts.get("location");
    String url = null;
    try {
      for (int i = 0; i < loc.length; i++) {
        url = completeLocation(loc[i]);
        Bundle b = bc.installBundle(url);
        out.println("Installed: " + showBundle(b));
        if (opts.get("-s") != null) {
          b.start(Bundle.START_ACTIVATION_POLICY);
          out.println("Started: " + showBundle(b));
        }
      }
    } catch (BundleException e) {
      Throwable t = e;
View Full Code Here

        final RequiredBundle[] rbl = pkgAdmin.getRequiredBundles(null);

        for(int i = 0; pkgs != null && i < pkgs.length; i++) {

          if(accept(pkgs[i])) {
            Bundle   fromB = pkgs[i].getExportingBundle();
            if (null==fromB) continue; // Ignore STALE epkgs

            Collection r = (Collection)bundleExports.get(fromB);
            if(r == null) {
              r = new TreeSet(pkgComparator);
View Full Code Here

    final RequiredBundle rb = (RequiredBundle) requiredBundleMap.get(b);
    if(rb != null) {
      return rb;
    }
    for (int i=0; rbl!=null && i<rbl.length; i++) {
      final Bundle rbb = rbl[i].getBundle();
      if (rbb != null && rbb.getBundleId()==b.getBundleId()) {
        requiredBundleMap.put(b, rbl[i]);
        return rbl[i];
      }
    }
    requiredBundleMap.put(b, null);
View Full Code Here

      Collection importedPkgs = pm.getImportedPackages(target);

      for(Iterator it = importedPkgs.iterator(); it.hasNext();) {
        ExportedPackage pkg = (ExportedPackage)it.next();

        Bundle exporter = pkg.getExportingBundle();
        if (null==exporter) continue;

        closure.add(exporter);

        // Then, get closure from the exporter, if not already
View Full Code Here

      Set closure = new TreeSet(Util.bundleIdComparator);

      ServiceReference[] srl = target.getServicesInUse();

      for(int i = 0; srl != null && i < srl.length; i++) {
        Bundle b = srl[i].getBundle();
        if (null==b) continue; // Unregistered service.

        closure.add(b);

        if(!handled.contains(b)) {
View Full Code Here

    int levelMax = -1;

    int n = 0;
    int lastLevel = -1;
    for(Iterator it = all.iterator(); it.hasNext(); ) {
      Bundle b = (Bundle)it.next();
      int level = -1;
      try {
        level = sl.getBundleStartLevel(b);
      } catch (Exception ignored) {
      }

      levelMax = Math.max(level, levelMax);
      if(level != -1 && level != lastLevel) {
        sb.append("-initlevel " + level + "\n");

        lastLevel = level;
      }
      sb.append("-install " +
                Text.replace(b.getLocation(), jarBase, "") +
                "\n");

      n++;
    }

    sb.append("-launch\n");

    n = 0;
    for(Iterator it = all.iterator(); it.hasNext(); ) {
      Bundle b = (Bundle)it.next();
      n++;
      if(b.getState() == Bundle.ACTIVE) {
        sb.append("-start " + n + "\n");
      }
    }

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

  public static Comparator bundleIdComparator = new BundleIdComparator();

  public static class BundleIdComparator implements Comparator {
    public int compare(Object o1, Object o2) {
      Bundle b1 = (Bundle)o1;
      Bundle b2 = (Bundle)o2;

      return (int)(b1.getBundleId() - b2.getBundleId());
    }
View Full Code Here

        for (Iterator it = importedPkgs.iterator(); it.hasNext(); ) {
          final ExportedPackage epkg = (ExportedPackage) it.next();
          sb.append(formatPackage( epkg, false ));
          sb.append("<br>");
          sb.append("&nbsp;&nbsp;");
          final Bundle exporter = epkg.getExportingBundle();
          if (exporter != null) {
            Util.bundleLink(sb, exporter);
          } else {
            sb.append("STALE");
          }
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.