Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java67
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java22
2 files changed, 72 insertions, 17 deletions
diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java
index 131caba01..90c86a99c 100644
--- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java
+++ b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeConfigurator.java
@@ -31,7 +31,7 @@ import org.osgi.framework.launch.Framework;
import org.osgi.service.framework.CompositeBundle;
import org.osgi.service.framework.CompositeBundleFactory;
-public class CompositeConfigurator implements HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry {
+public class CompositeConfigurator implements SynchronousBundleListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry {
// the base adaptor
private BaseAdaptor adaptor;
@@ -39,6 +39,8 @@ public class CompositeConfigurator implements HookConfigurator, AdaptorHook, Cla
private ServiceRegistration factoryService;
// the system bundle context
private BundleContext systemContext;
+ // The composite resolver helpers
+ private final Collection helpers = new ArrayList(0);
public void addHooks(HookRegistry hookRegistry) {
// this is an adaptor hook to register the composite factory and
@@ -62,6 +64,8 @@ public class CompositeConfigurator implements HookConfigurator, AdaptorHook, Cla
*/
public void frameworkStart(BundleContext context) throws BundleException {
this.systemContext = context;
+ context.addBundleListener(this);
+ addHelpers(context.getBundles());
// this is a composite resolve helper registry; add it to the resolver
((ResolverImpl) adaptor.getState().getResolver()).setCompositeResolveHelperRegistry(this);
// register this as the composite bundle factory
@@ -75,6 +79,8 @@ public class CompositeConfigurator implements HookConfigurator, AdaptorHook, Cla
factoryService = null;
// stop any child frameworks than may still be running.
stopFrameworks();
+ context.removeBundleListener(this);
+ removeAllHelpers();
}
public void frameworkStopping(BundleContext context) {
@@ -142,10 +148,18 @@ public class CompositeConfigurator implements HookConfigurator, AdaptorHook, Cla
}
public CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle) {
- // EquinoxComposite bundles implement the resolver helper
- Bundle composite = systemContext.getBundle(bundle.getBundleId());
- // If we found a resolver helper bundle; return it
- return (CompositeResolveHelper) ((!(composite instanceof CompositeResolveHelper)) ? null : composite);
+ // Composite bundles implement the resolver helper
+ synchronized (helpers) {
+ if (helpers.size() == 0)
+ return null;
+ for (Iterator iHelpers = helpers.iterator(); iHelpers.hasNext();) {
+ CompositeBase composite = (CompositeBase) iHelpers.next();
+ if (composite.getBundleId() == bundle.getBundleId())
+ // If we found a resolver helper bundle; return it
+ return composite;
+ }
+ return null;
+ }
}
public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain) {
@@ -179,4 +193,47 @@ public class CompositeConfigurator implements HookConfigurator, AdaptorHook, Cla
// nothing
return null;
}
+
+ private void addHelpers(Bundle[] bundles) {
+ synchronized (helpers) {
+ for (int i = 0; i < bundles.length; i++)
+ addHelper(bundles[i]);
+ }
+ }
+
+ private void addHelper(Bundle bundle) {
+ if (!(bundle instanceof CompositeBase))
+ return;
+ synchronized (helpers) {
+ if (!helpers.contains(bundle))
+ helpers.add(bundle);
+ }
+ }
+
+ private void removeHelper(Bundle bundle) {
+ if (!(bundle instanceof CompositeBase))
+ return;
+ synchronized (helpers) {
+ helpers.remove(bundle);
+ }
+ }
+
+ private void removeAllHelpers() {
+ synchronized (helpers) {
+ helpers.clear();
+ }
+ }
+
+ public void bundleChanged(BundleEvent event) {
+ switch (event.getType()) {
+ case BundleEvent.INSTALLED :
+ addHelper(event.getBundle());
+ break;
+ case BundleEvent.UNINSTALLED :
+ removeHelper(event.getBundle());
+ break;
+ default :
+ break;
+ }
+ }
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
index 0457ccfb6..b01ca97f1 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
@@ -88,18 +88,16 @@ public class PackageAdminImpl implements PackageAdmin {
public ExportedPackage[] getExportedPackages(Bundle bundle) {
ArrayList allExports = new ArrayList();
- synchronized (framework.bundles) {
- FrameworkAdaptor adaptor = framework.adaptor;
- if (adaptor == null)
- return null;
- ExportPackageDescription[] allDescriptions = adaptor.getState().getExportedPackages();
- for (int i = 0; i < allDescriptions.length; i++) {
- ExportedPackageImpl exportedPackage = createExportedPackage(allDescriptions[i]);
- if (exportedPackage == null)
- continue;
- if (bundle == null || exportedPackage.getBundle() == bundle)
- allExports.add(exportedPackage);
- }
+ FrameworkAdaptor adaptor = framework.adaptor;
+ if (adaptor == null)
+ return null;
+ ExportPackageDescription[] allDescriptions = adaptor.getState().getExportedPackages();
+ for (int i = 0; i < allDescriptions.length; i++) {
+ ExportedPackageImpl exportedPackage = createExportedPackage(allDescriptions[i]);
+ if (exportedPackage == null)
+ continue;
+ if (bundle == null || exportedPackage.getBundle() == bundle)
+ allExports.add(exportedPackage);
}
return (ExportedPackage[]) (allExports.size() == 0 ? null : allExports.toArray(new ExportedPackage[allExports.size()]));
}

Back to the top