Java Code Examples for org.osgi.framework.Bundle#update()

The following examples show how to use org.osgi.framework.Bundle#update() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static void updateBundle(BundleContext bc,
                                Bundle bu,
                                String resource)
  throws BundleException
{
  try {
    System.out.println("updateBundle(" +bu.getSymbolicName()
                       +", " + resource + ")");
    URL url = bc.getBundle().getResource(resource);
    if(url == null) {
      throw new BundleException("No resource " + resource);
    }
    InputStream in = url.openStream();
    if(in == null) {
      throw new BundleException("No resource " + resource);
    }
    bu.update(in);
  } catch (IOException e) {
    throw new BundleException
      ("Failed to get input stream for " + resource + ": " + e);
  }
}
 
Example 2
public BundleDTO updateBundle(long id) throws BundleException {
	Bundle b  = context.getBundle(id);
	if(b == null)
		return null;
	
	b.update();
	return b.adapt(BundleDTO.class);
}
 
Example 3
public BundleDTO updateBundle(long id, String url) throws BundleException, MalformedURLException, IOException {
	Bundle b  = context.getBundle(id);
	if(b == null)
		return null;
	
	URL u = new URL(url);
	b.update(u.openStream());
	return b.adapt(BundleDTO.class);
}
 
Example 4
public static void updateBundle(BundleContext context, Bundle bundle) {
  try{
    if (bundle.getLocation().startsWith(LOC_PROT)) {
      String resource = bundle.getLocation().substring(LOC_PROT.length());
      URL url = context.getBundle().getResource(resource);
      bundle.update(url.openStream());
    } else {
      bundle.update();
    }
  } catch(Exception e) {
    /* print the error */
    System.out.println("ERROR in Util installBundle()" + e);
    e.printStackTrace();
  }
}
 
Example 5
public static void updateBundle(BundleContext context, Bundle bundle) {
  try{
    if (bundle.getLocation().startsWith(LOC_PROT)) {
      String resource = bundle.getLocation().substring(LOC_PROT.length());
      URL url = context.getBundle().getResource(resource);
      bundle.update(url.openStream());
    } else {
      bundle.update();
    }
  }catch(Exception e){
    /* print the error */
    System.out.println("ERROR in Util installBundle()" + e);
    e.printStackTrace();
  }
}
 
Example 6
public static void updateBundle(BundleContext context, Bundle bundle) {
  try{
    if (bundle.getLocation().startsWith(LOC_PROT)) {
      String resource = bundle.getLocation().substring(LOC_PROT.length());
      URL url = context.getBundle().getResource(resource);
      bundle.update(url.openStream());
    } else {
      bundle.update();
    }
  } catch(Exception e) {
    /* print the error */
    System.out.println("ERROR in Util installBundle()" + e);
    e.printStackTrace();
  }
}
 
Example 7
Source Project: ACDD   File: OpenAtlas.java    License: MIT License 5 votes vote down vote up
public void updateBundle(String pkgName, InputStream inputStream)
        throws BundleException {
    Bundle bundle = Framework.getBundle(pkgName);
    if (bundle != null) {
        bundle.update(inputStream);
        return;
    }
    throw new BundleException("Could not update bundle " + pkgName
            + ", because could not find it");
}
 
Example 8
Source Project: ACDD   File: OpenAtlas.java    License: MIT License 5 votes vote down vote up
public void updateBundle(String pkgName, File mBundleFile) throws BundleException {
    if (!mBundleFile.exists()) {
        throw new BundleException("file not  found" + mBundleFile.getAbsolutePath());
    }
    Bundle bundle = Framework.getBundle(pkgName);
    if (bundle != null) {
        bundle.update(mBundleFile);
        return;
    }
    throw new BundleException("Could not update bundle " + pkgName
            + ", because could not find it");
}
 
Example 9
Source Project: ACDD   File: Framework.java    License: MIT License 5 votes vote down vote up
static void installOrUpdate(String[] locations, File[] archiveFiles) throws BundleException {
    if (locations == null || archiveFiles == null || locations.length != archiveFiles.length) {
        throw new IllegalArgumentException("locations and files must not be null and must be same length");
    }
    String valueOf = String.valueOf(System.currentTimeMillis());
    File file = new File(new File(STORAGE_LOCATION, "wal"), valueOf);
    file.mkdirs();
    int i = 0;
    while (i < locations.length) {
        if (!(locations[i] == null || archiveFiles[i] == null)) {
            try {
                BundleLock.WriteLock(locations[i]);
                Bundle bundle = getBundle(locations[i]);
                if (bundle != null) {
                    bundle.update(archiveFiles[i]);
                } else {
                    BundleImpl bundleImpl = new BundleImpl(new File(file, locations[i]), locations[i],  null, archiveFiles[i], false);
                }
                BundleLock.WriteUnLock(locations[i]);
            } catch (Throwable th) {
                BundleLock.WriteUnLock(locations[i]);
            }
        }
        i++;
    }
    writeAheads.add(valueOf);
    storeMetadata();
}
 
Example 10
Source Project: AtlasForAndroid   File: Atlas.java    License: MIT License 5 votes vote down vote up
public void updateBundle(String str, InputStream inputStream) throws BundleException {
    Bundle bundle = Framework.getBundle(str);
    if (bundle != null) {
        bundle.update(inputStream);
        return;
    }
    throw new BundleException("Could not update bundle " + str + ", because could not find it");
}
 
Example 11
Source Project: AtlasForAndroid   File: Atlas.java    License: MIT License 5 votes vote down vote up
public void updateBundle(String str, File file) throws BundleException {
    Bundle bundle = Framework.getBundle(str);
    if (bundle != null) {
        bundle.update(file);
        return;
    }
    throw new BundleException("Could not update bundle " + str + ", because could not find it");
}
 
Example 12
Source Project: AtlasForAndroid   File: Framework.java    License: MIT License 5 votes vote down vote up
static void installOrUpdate(String[] strArr, File[] fileArr) throws BundleException {
    if (strArr == null || fileArr == null || strArr.length != fileArr.length) {
        throw new IllegalArgumentException("locations and files must not be null and must be same length");
    }
    String valueOf = String.valueOf(System.currentTimeMillis());
    File file = new File(new File(STORAGE_LOCATION, "wal"), valueOf);
    file.mkdirs();
    int i = 0;
    while (i < strArr.length) {
        if (!(strArr[i] == null || fileArr[i] == null)) {
            try {
                BundleLock.WriteLock(strArr[i]);
                Bundle bundle = getBundle(strArr[i]);
                if (bundle != null) {
                    bundle.update(fileArr[i]);
                } else {
                    BundleImpl bundleImpl = new BundleImpl(new File(file, strArr[i]), strArr[i], new BundleContextImpl(), null, fileArr[i], false);
                }
                BundleLock.WriteUnLock(strArr[i]);
            } catch (Throwable th) {
                BundleLock.WriteUnLock(strArr[i]);
            }
        }
        i++;
    }
    writeAheads.add(valueOf);
    storeMetadata();
}