Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-08-10 12:29:07 -0400
committerThomas Watson2006-08-10 12:29:07 -0400
commit150b3d1d44d601f61394155919ff48a05943c68b (patch)
treeb6e469fc292f1bf4e322c2561d9f20219ec3516e
parent987345e6e6771e4db3961f4a9e4876889ae86285 (diff)
downloadrt.equinox.framework-150b3d1d44d601f61394155919ff48a05943c68b.tar.gz
rt.equinox.framework-150b3d1d44d601f61394155919ff48a05943c68b.tar.xz
rt.equinox.framework-150b3d1d44d601f61394155919ff48a05943c68b.zip
Bug 153358 ServiceReference.isAssignableTo does not pay attention to boot delegation
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java2
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java6
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleLoader.java15
3 files changed, 21 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
index e42d792f4..0a657dcb7 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
@@ -503,7 +503,7 @@ public class BundleLoader implements ClassLoaderDelegate {
return result;
}
- private boolean isBootDelegationPackage(String name) {
+ boolean isBootDelegationPackage(String name) {
if (bundle.framework.bootDelegateAll)
return true;
if (bundle.framework.bootDelegation != null)
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
index 0bc4e9900..0c25ebdff 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/ServiceReferenceImpl.java
@@ -238,6 +238,12 @@ public class ServiceReferenceImpl implements ServiceReference, Comparable {
PackageSource consumerSource = consumerBL.getPackageSource(pkgName);
if (consumerSource == null)
return true;
+ // work around the issue when the package is in the EE and we delegate to boot for that package
+ if (producerBL.isBootDelegationPackage(pkgName)) {
+ SystemBundleLoader systemLoader = (SystemBundleLoader) registration.framework.systemBundle.getBundleLoader();
+ if (systemLoader.isEEPackage(pkgName))
+ return true; // in this case we have a common source from the EE
+ }
// 4) For the registrant bundle, find the wiring for the package.
PackageSource producerSource = producerBL.getPackageSource(pkgName);
if (producerSource == null) {
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleLoader.java
index 46497ee9b..986dc388f 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/SystemBundleLoader.java
@@ -13,7 +13,8 @@ package org.eclipse.osgi.framework.internal.core;
import java.io.IOException;
import java.net.URL;
-import java.util.Enumeration;
+import java.util.*;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.osgi.framework.BundleException;
/**
@@ -21,7 +22,9 @@ import org.osgi.framework.BundleException;
* to load a resource that is exported by the System Bundle.
*/
public class SystemBundleLoader extends BundleLoader {
+ public static final String EQUINOX_EE = "x-equinox-ee"; //$NON-NLS-1$
ClassLoader classLoader;
+ private HashSet eePackages;
/**
* @param bundle The system bundle.
@@ -30,6 +33,13 @@ public class SystemBundleLoader extends BundleLoader {
*/
protected SystemBundleLoader(BundleHost bundle, BundleLoaderProxy proxy) throws BundleException {
super(bundle, proxy);
+ ExportPackageDescription[] exports = proxy.getBundleDescription().getSelectedExports();
+ if (exports != null && exports.length > 0) {
+ eePackages = new HashSet(exports.length);
+ for (int i = 0; i < exports.length; i++)
+ if (((Integer) exports[i].getDirective(EQUINOX_EE)).intValue() >= 0)
+ eePackages.add(exports[i].getName());
+ }
this.classLoader = getClass().getClassLoader();
}
@@ -99,4 +109,7 @@ public class SystemBundleLoader extends BundleLoader {
// Do nothing.
}
+ public boolean isEEPackage(String pkgName) {
+ return eePackages.contains(pkgName);
+ }
}

Back to the top