Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2013-12-03 20:58:56 +0000
committerThomas Watson2013-12-03 20:58:56 +0000
commitbfae5de40933cd07593087ddcded3fe21cb436c1 (patch)
tree01d86b6c67dd6e70f73c4511bf49a8bb7622bde1
parent60867ec6c03325a77fcd6a6006da38046aea1b7a (diff)
downloadrt.equinox.framework-bfae5de40933cd07593087ddcded3fe21cb436c1.tar.gz
rt.equinox.framework-bfae5de40933cd07593087ddcded3fe21cb436c1.tar.xz
rt.equinox.framework-bfae5de40933cd07593087ddcded3fe21cb436c1.zip
Bug 423093 - Allow ClassLoaderHook to provide a parent class loader
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/ClassLoaderHook.java13
2 files changed, 23 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 92538b4ae..b2dbb2bc3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -16,6 +16,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.Module.Settings;
import org.eclipse.osgi.container.Module.State;
+import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook;
import org.eclipse.osgi.internal.loader.*;
import org.eclipse.osgi.internal.permadmin.BundlePermissions;
import org.eclipse.osgi.service.debug.DebugOptions;
@@ -45,6 +46,15 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
}
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) {
+ // allow hooks to determine the parent class loader
+ for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) {
+ ClassLoader parent = hook.getModuleClassLoaderParent(configuration);
+ if (parent != null) {
+ // first one to return non-null wins.
+ return parent;
+ }
+ }
+ // DEFAULT behavior:
// check property for specified parent
// check the osgi defined property first
String type = configuration.getConfiguration(Constants.FRAMEWORK_BUNDLE_PARENT);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/ClassLoaderHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/ClassLoaderHook.java
index 8cc43a89c..fba067d67 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/ClassLoaderHook.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/ClassLoaderHook.java
@@ -264,4 +264,17 @@ public abstract class ClassLoaderHook {
// do nothing
}
+ /**
+ * Returns the parent class loader to be used by all ModuleClassLoaders.
+ * A {@code null} value may be returned if this hook does not supply the parent.
+ * Only one hook is able to provide the implementation of the parent class loader
+ * and the first one to return non-null wins.
+ * @param configuration the equinox configuration
+ * @return the parent class loader to be used by all ModuleClassLoaders
+ */
+ public ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) {
+ // do nothing by default
+ return null;
+ }
+
}

Back to the top