diff options
author | Thomas Watson | 2019-02-15 15:41:54 +0000 |
---|---|---|
committer | Thomas Watson | 2019-02-15 16:43:17 +0000 |
commit | 9e200a3c15f8161fef93b241012ecb3d0f1f1b7d (patch) | |
tree | e0a86411948a370e61ce2f8f17203afc4807a417 /bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a | |
parent | 27e73a64c9a38f98b23838f2279c227238541f09 (diff) | |
download | rt.equinox.framework-9e200a3c15f8161fef93b241012ecb3d0f1f1b7d.tar.gz rt.equinox.framework-9e200a3c15f8161fef93b241012ecb3d0f1f1b7d.tar.xz rt.equinox.framework-9e200a3c15f8161fef93b241012ecb3d0f1f1b7d.zip |
Bug 544477 - allow hook to prevent resource load
Change-Id: I6286f7b427d54ad0f3961bd2b21658cb573552d7
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a')
-rw-r--r-- | bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java index 61e86e9a0..0daec7d29 100644 --- a/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java +++ b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.osgi.tests.classloader.hooks.a; +import java.net.URL; +import java.util.NoSuchElementException; import org.eclipse.osgi.container.Module; import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook; import org.eclipse.osgi.internal.hookregistry.HookConfigurator; @@ -27,6 +29,8 @@ public class TestHookConfigurator implements HookConfigurator { private static final String RECURSION_LOAD = "classloader.hooks.a.recursion.load"; private static final String RECURSION_LOAD_SUPPORTED = "classloader.hooks.a.recursion.load.supported"; private static final String FILTER_CLASS_PATHS = "classloader.hooks.a.filter.class.paths"; + private static final String PREVENT_RESOURCE_LOAD_PRE = "classloader.hooks.a.fail.resource.load.pre"; + private static final String PREVENT_RESOURCE_LOAD_POST = "classloader.hooks.a.fail.resource.load.post"; final ThreadLocal<Boolean> doingRecursionLoad = new ThreadLocal<Boolean>() { protected Boolean initialValue() { return false; @@ -81,6 +85,20 @@ public class TestHookConfigurator implements HookConfigurator { } return super.getClassPathEntries(name, manager); } + + @Override + public void preFindLocalResource(String name, ClasspathManager manager) { + if (Boolean.getBoolean(PREVENT_RESOURCE_LOAD_PRE)) { + throw new NoSuchElementException(); + } + } + + @Override + public void postFindLocalResource(String name, URL resource, ClasspathManager manager) { + if (Boolean.getBoolean(PREVENT_RESOURCE_LOAD_POST)) { + throw new NoSuchElementException(); + } + } }); } } |