Пример #1
0
  /**
   * Returns the byte representation of the image corresponding to the given identifier.
   *
   * @param imageID the identifier of the image
   * @return the byte representation of the image corresponding to the given identifier.
   */
  private static byte[] getImageInBytes(String imageID) {
    InputStream in = getResources().getImageInputStream(imageID);

    if (in == null) return null;
    byte[] image = null;
    try {
      image = new byte[in.available()];

      in.read(image);
    } catch (IOException e) {
      logger.error("Failed to load image:" + imageID, e);
    }

    return image;
  }
 @Override
 public void update(InputStream input) throws BundleException {
   getEquinoxContainer().checkAdminPermission(this, AdminPermission.LIFECYCLE);
   try {
     if (input != null) input.close();
   } catch (IOException e) {
     // do nothing
   }
   ((EquinoxSystemModule) getModule()).asyncUpdate();
 }
 private String getManifestEntry(File bundleFile, String entry) {
   try {
     String value = null;
     if (bundleFile.isDirectory()) {
       File m = new File(bundleFile, "META-INF/MANIFEST.MF");
       InputStream os;
       os = new FileInputStream(m);
       Manifest mf;
       mf = new Manifest(os);
       value = mf.getMainAttributes().getValue(entry);
       os.close();
     } else {
       JarFile bundleJar = new JarFile(bundleFile);
       value = bundleJar.getManifest().getMainAttributes().getValue(entry);
     }
     if (value.indexOf(";") > -1) {
       String[] valueElements = value.split(";");
       return valueElements[0];
     }
     return value;
   } catch (IOException e) {
     return null;
   }
 }
Пример #4
0
 public Bundle installBundle(String location, InputStream in) throws BundleException {
   Context c;
   try {
     in.close();
     try {
       @SuppressWarnings("unused")
       URL url = new URL(location);
     } catch (MalformedURLException e) {
       throw new BundleException(
           "For the mini framework, the location must be a proper URL even though this is not required by the specification "
               + location,
           e);
     }
     c = new Context(this, last, ++ID, location);
     bundles.put(new Long(c.id), c);
     last = c;
     return c;
   } catch (Exception e) {
     throw new BundleException("Can't install " + location, e);
   }
 }