use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class EquinoxContainerAdaptor method invalidateWiring.
@Override
public void invalidateWiring(ModuleWiring moduleWiring, ModuleLoader current) {
if (current instanceof BundleLoader) {
BundleLoader bundleLoader = (BundleLoader) current;
bundleLoader.close();
}
long updatedTimestamp = storage.getModuleDatabase().getRevisionsTimestamp();
if (System.getSecurityManager() != null && updatedTimestamp != lastSecurityAdminFlush.getAndSet(updatedTimestamp)) {
storage.getSecurityAdmin().clearCaches();
List<Module> modules = storage.getModuleContainer().getModules();
for (Module module : modules) {
for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) {
Generation generation = (Generation) revision.getRevisionInfo();
if (generation != null) {
ProtectionDomain domain = generation.getDomain();
if (domain != null) {
((BundlePermissions) domain.getPermissions()).clearPermissionCache();
}
}
}
}
}
clearManifestCache(moduleWiring);
}
use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class PackageAdminImpl method getBundleType.
public int getBundleType(Bundle bundle) {
Module module = StartLevelImpl.getModule(bundle);
if (module == null) {
return 0;
}
List<BundleRevision> revisions = module.getRevisions().getRevisions();
if (revisions.isEmpty()) {
return 0;
}
return (revisions.get(0).getTypes() & BundleRevision.TYPE_FRAGMENT) != 0 ? PackageAdmin.BUNDLE_TYPE_FRAGMENT : 0;
}
use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class PackageAdminImpl method getWiring.
private ModuleWiring getWiring(Bundle bundle) {
Module module = StartLevelImpl.getModule(bundle);
if (module == null) {
return null;
}
List<ModuleRevision> revisions = module.getRevisions().getModuleRevisions();
if (revisions.isEmpty()) {
return null;
}
return revisions.get(0).getWiring();
}
use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class EclipseLazyStarter method postFindLocalClass.
@Override
public void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager) throws ClassNotFoundException {
if (initiatingClassName.get() != name)
return;
initiatingClassName.set(null);
Deque<ClasspathManager> stack = activationStack.get();
if (stack == null || stack.isEmpty())
return;
// if we have a stack we must clear it even if (clazz == null)
List<ClasspathManager> managers = new ArrayList<>(stack);
stack.clear();
if (clazz == null)
return;
for (ClasspathManager managerElement : managers) {
if (errors.get(managerElement) != null) {
if (container.getConfiguration().throwErrorOnFailedStart)
throw errors.get(managerElement);
continue;
}
// The bundle must be started.
// Note that another thread may already be starting this bundle;
// In this case we will timeout after a default of 5 seconds and record the BundleException
long startTime = System.currentTimeMillis();
Module m = managerElement.getGeneration().getRevision().getRevisions().getModule();
try {
// do not persist the start of this bundle
secureAction.start(m, StartOptions.LAZY_TRIGGER);
} catch (BundleException e) {
Bundle bundle = managerElement.getGeneration().getRevision().getBundle();
if (e.getType() == BundleException.STATECHANGE_ERROR) {
String message = NLS.bind(Msg.ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP, new Object[] { Thread.currentThread(), name, m.getStateChangeOwner(), bundle, new Long(System.currentTimeMillis() - startTime) });
container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, message, e);
continue;
}
String message = NLS.bind(Msg.ECLIPSE_CLASSLOADER_ACTIVATION, bundle.getSymbolicName(), Long.toString(bundle.getBundleId()));
ClassNotFoundException error = new ClassNotFoundException(message, e);
errors.put(managerElement, error);
if (container.getConfiguration().throwErrorOnFailedStart) {
container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, message, e, null);
throw error;
}
container.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(message, e));
}
}
}
use of org.eclipse.osgi.container.Module in project rt.equinox.framework by eclipse.
the class BundleContextImpl method getBundles.
/**
* Retrieve a list of all installed bundles.
* The list is valid at the time
* of the call to getBundles, but the framework is a very dynamic
* environment and bundles can be installed or uninstalled at anytime.
*
* @return An array of {@link Bundle} objects, one
* object per installed bundle.
*/
public Bundle[] getBundles() {
List<Module> modules = container.getStorage().getModuleContainer().getModules();
List<Bundle> bundles = new ArrayList<>(modules.size());
for (Module module : modules) {
bundles.add(module.getBundle());
}
notifyFindHooks(this, bundles);
return bundles.toArray(new Bundle[bundles.size()]);
}
Aggregations