use of org.osgi.framework.Bundle in project jersey by jersey.
the class AbstractWebAppTest method bundleList.
private String bundleList() {
StringBuilder sb = new StringBuilder();
sb.append("-- Bundle list -- \n");
for (Bundle b : bundleContext.getBundles()) {
sb.append(String.format("%1$5s", "[" + b.getBundleId() + "]")).append(" ").append(String.format("%1$-70s", b.getSymbolicName())).append(" | ").append(String.format("%1$-20s", b.getVersion())).append(" |");
sb.append(stateString(b)).append(" |");
sb.append(b.getLocation()).append("\n");
}
sb.append("-- \n\n");
return sb.toString();
}
use of org.osgi.framework.Bundle in project atlas by alibaba.
the class BundleInstaller method call.
@Override
public synchronized Void call() throws Exception {
Bundle bundle = null;
if (!mTransitive) {
for (int x = 0; x < mLocation.length; x++) {
if (FileUtils.getUsableSpace(Environment.getDataDirectory()) >= 5) {
if (mBundleSourceInputStream != null && mBundleSourceInputStream.length > x && mBundleSourceInputStream[x] != null) {
if ((bundle = getInstalledBundle(mLocation[x])) == null) {
bundle = Framework.installNewBundle(mLocation[x], mBundleSourceInputStream[x]);
}
if (bundle != null) {
((BundleImpl) bundle).optDexFile();
}
} else if (mBundleSourceFile != null && mBundleSourceFile.length > x && mBundleSourceFile[x] != null) {
if ((bundle = getInstalledBundle(mLocation[x])) == null) {
bundle = Framework.installNewBundle(mLocation[x], mBundleSourceFile[x]);
}
if (bundle != null) {
((BundleImpl) bundle).optDexFile();
}
} else {
if ((bundle = getInstalledBundle(mLocation[x])) == null && AtlasBundleInfoManager.instance().isInternalBundle(mLocation[x])) {
bundle = installBundleFromApk(mLocation[x]);
if (bundle != null) {
((BundleImpl) bundle).optDexFile();
}
}
}
} else {
throw new LowDiskException("no enough space");
}
}
} else {
for (int x = 0; x < mLocation.length; x++) {
List<String> bundlesForInstall = AtlasBundleInfoManager.instance().getBundleInfo(mLocation[x]).getTotalDependency();
Log.e("BundleInstaller", mLocation[x] + "-->" + bundlesForInstall.toString());
for (String bundleName : bundlesForInstall) {
if ((bundle = getInstalledBundle(bundleName)) == null) {
if (FileUtils.getUsableSpace(Environment.getDataDirectory()) >= 5) {
//has enough space
if (AtlasBundleInfoManager.instance().isInternalBundle(bundleName)) {
bundle = installBundleFromApk(bundleName);
if (bundle != null) {
((BundleImpl) bundle).optDexFile();
}
}
} else {
throw new LowDiskException("no enough space");
}
} else {
if (bundle != null && ((BundleImpl) bundle).getArchive() != null && !((BundleImpl) bundle).getArchive().isDexOpted()) {
((BundleImpl) bundle).optDexFile();
}
}
}
}
}
return null;
}
use of org.osgi.framework.Bundle in project atlas by alibaba.
the class BundleInstaller method installBundleFromApk.
private Bundle installBundleFromApk(String bundleName) throws Exception {
Bundle bundle = null;
findBundleSource(bundleName);
if (mTmpBundleSourceFile != null) {
bundle = Framework.installNewBundle(bundleName, mTmpBundleSourceFile);
} else if (mTmpBundleSourceInputStream != null) {
bundle = Framework.installNewBundle(bundleName, mTmpBundleSourceInputStream);
} else {
throw new IOException("can not find bundle source file");
}
return bundle;
}
use of org.osgi.framework.Bundle in project atlas by alibaba.
the class Framework method addValue.
/**
* add a value to a value list in a Map.
*
* @param map the map.
* @param key the key.
* @param value the value to be added to the list.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
static void addValue(final Map map, final Object key, final Object value) {
List values;
if ((values = (List) map.get(key)) == null) {
values = new ArrayList<Bundle>();
}
values.add(value);
map.put(key, values);
}
use of org.osgi.framework.Bundle in project atlas by alibaba.
the class Atlas method uninstallBundle.
@Deprecated
public void uninstallBundle(final String location) throws BundleException {
Bundle bundle = Framework.getBundle(location);
if (bundle != null) {
BundleImpl b = (BundleImpl) bundle;
File delDir = null;
try {
File soFile = b.getArchive().getArchiveFile();
if (soFile.canWrite()) {
soFile.delete();
}
b.getArchive().purge();
delDir = b.getArchive().getCurrentRevision().getRevisionDir();
bundle.uninstall();
if (delDir != null) {
Framework.deleteDirectory(delDir);
}
} catch (Exception e) {
}
} else {
throw new BundleException("Could not uninstall bundle " + location + ", because could not find it");
}
}
Aggregations