コード例 #1
0
  public Map getSystemProperties() {
    Map map = new HashMap();
    Properties props = System.getProperties();

    for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) props.get(key);
      map.put(key, val);
    }
    return map;
  }
コード例 #2
0
 void putExportPackage(Map map, ExportedPackage pkg) {
   if (pkg != null) {
     Long[] bids;
     Bundle[] bl = pkg.getImportingBundles();
     if (bl == null) {
       bids = new Long[0];
     } else {
       bids = new Long[bl.length];
       for (int i = 0; i < bids.length; i++) {
         bids[i] = new Long(bl[i].getBundleId());
       }
     }
     map.put("getExportingBundle", new Long(pkg.getExportingBundle().getBundleId()));
     map.put("getImportingBundles", bids);
     map.put("getName", pkg.getName());
     map.put("getSpecificationVersion", pkg.getSpecificationVersion());
     map.put("isRemovalPending", pkg.isRemovalPending() ? Boolean.TRUE : Boolean.FALSE);
   }
 }
コード例 #3
0
  public Map getBundleManifest(long bundleId) {
    Bundle b = Activator.bc.getBundle(bundleId);

    Dictionary d = b.getHeaders();

    Map result = new HashMap();

    int i = 0;
    for (Enumeration e = d.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) d.get(key);

      result.put(key, val);

      i += 2;
    }

    result.remove("Application-Icon");
    return result;
  }
コード例 #4
0
  public Map getServiceProperties(long sid) {
    try {
      ServiceReference[] srl = Activator.bc.getServiceReferences(null, "(service.id=" + sid + ")");

      String[] keys = srl[0].getPropertyKeys();

      Map result = new HashMap();

      for (int i = 0; i < keys.length; i++) {
        String key = keys[i];
        Object val = srl[0].getProperty(keys[i]);
        //      Object strVal = Util.encodeAsString(val);

        result.put(key, val);
      }

      return result;

    } catch (Exception e) {
      throw new IllegalArgumentException(
          "Failed to get service properties " + "for service.id=" + sid + ", " + e);
    }
  }