use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class ServiceRegistry method hasListenServicePermission.
/**
* Check for permission to listen to a service.
*/
static boolean hasListenServicePermission(ServiceEvent event, BundleContextImpl context) {
ModuleRevision revision = context.getBundleImpl().getModule().getCurrentRevision();
if (revision == null) {
return false;
}
ProtectionDomain domain = ((Generation) revision.getRevisionInfo()).getDomain();
if (domain == null) {
return true;
}
return domain.implies(new ServicePermission(event.getServiceReference(), ServicePermission.GET));
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class SignedBundleHook method getSignedContent.
public SignedContent getSignedContent(Bundle bundle) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException {
final Generation generation = (Generation) ((EquinoxBundle) bundle).getModule().getCurrentRevision().getRevisionInfo();
StorageHookImpl hook = generation.getStorageHook(SignedStorageHook.class);
SignedContent result = hook != null ? hook.signedContent : null;
if (result != null)
// just reuse the signed content the storage hook
return result;
// must create a new signed content using the raw file
if (System.getSecurityManager() == null)
return getSignedContent(generation.getBundleFile().getBaseFile());
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<SignedContent>() {
public SignedContent run() throws Exception {
return getSignedContent(generation.getBundleFile().getBaseFile());
}
});
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
if (e.getException() instanceof InvalidKeyException)
throw (InvalidKeyException) e.getException();
if (e.getException() instanceof SignatureException)
throw (SignatureException) e.getException();
if (e.getException() instanceof CertificateException)
throw (CertificateException) e.getException();
if (e.getException() instanceof NoSuchAlgorithmException)
throw (NoSuchAlgorithmException) e.getException();
if (e.getException() instanceof NoSuchProviderException)
throw (NoSuchProviderException) e.getException();
// $NON-NLS-1$
throw new RuntimeException("Unknown error.", e.getException());
}
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class FrameworkExtensionInstaller method getExtensionFiles.
/**
* Returns a list of classpath files for an extension bundle
* @param revision revision for the extension bundle
* @return a list of classpath files for an extension bundle
*/
private File[] getExtensionFiles(ModuleRevision revision) {
List<ModuleCapability> metaDatas = revision.getModuleCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE);
@SuppressWarnings("unchecked") List<String> paths = metaDatas.isEmpty() ? null : (List<String>) metaDatas.get(0).getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_CLASSPATH);
if (paths == null) {
paths = new ArrayList<>(1);
// $NON-NLS-1$
paths.add(".");
}
if (configuration.inDevelopmentMode()) {
String[] devPaths = configuration.getDevClassPath(revision.getSymbolicName());
for (String devPath : devPaths) {
paths.add(devPath);
}
}
List<File> results = new ArrayList<>(paths.size());
for (String path : paths) {
if (".".equals(path)) {
// $NON-NLS-1$
results.add(((Generation) revision.getRevisionInfo()).getBundleFile().getBaseFile());
} else {
File result = ((Generation) revision.getRevisionInfo()).getBundleFile().getFile(path, false);
if (result != null)
results.add(result);
}
}
return results.toArray(new File[results.size()]);
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class BundleLocalizationImpl method getLocalization.
/**
* The getLocalization method gets a ResourceBundle object for the given
* locale and bundle.
*
* @return A <code>ResourceBundle</code> object for the given bundle and locale.
* If null is passed for the locale parameter, the default locale is used.
*/
public ResourceBundle getLocalization(Bundle bundle, String locale) {
Module m = ((EquinoxBundle) bundle).getModule();
ModuleRevision r = m.getCurrentRevision();
Generation g = (Generation) r.getRevisionInfo();
return g.getResourceBundle(locale);
}
use of org.eclipse.osgi.storage.BundleInfo.Generation in project rt.equinox.framework by eclipse.
the class Storage method refreshStaleBundles.
private void refreshStaleBundles() throws BundleException {
Collection<Module> needsRefresh = new ArrayList<>(0);
// First uninstall any modules that had their content changed or deleted
for (Module module : moduleContainer.getModules()) {
if (module.getId() == Constants.SYSTEM_BUNDLE_ID)
continue;
ModuleRevision revision = module.getCurrentRevision();
Generation generation = (Generation) revision.getRevisionInfo();
if (needsDiscarding(generation)) {
needsRefresh.add(module);
moduleContainer.uninstall(module);
generation.delete();
}
}
// because the runtime version changed.
if (refreshMRBundles.get()) {
needsRefresh.addAll(refreshMRJarBundles());
}
// refresh the modules that got deleted or are Multi-Release bundles
if (!needsRefresh.isEmpty()) {
moduleContainer.refresh(needsRefresh);
}
}
Aggregations