From: Decebal Suiu Date: Tue, 5 Jan 2016 13:21:52 +0000 (+0200) Subject: Use PluginClassLoader.findResource instead of getResource X-Git-Tag: release-0.12.0~7^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ec60800452476fd9019e6eabd3d20b1bdb5528ca;p=pf4j.git Use PluginClassLoader.findResource instead of getResource --- diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java index 4937cda..03a6bab 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java @@ -47,7 +47,6 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { @Override public Map> readClasspathStorages() { log.debug("Reading extensions storages from classpath"); - Map> result = new LinkedHashMap<>(); Set bucket = new HashSet<>(); @@ -80,7 +79,6 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { @Override public Map> readPluginsStorages() { log.debug("Reading extensions storages from plugins"); - Map> result = new LinkedHashMap<>(); List plugins = pluginManager.getPlugins(); @@ -90,7 +88,7 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { Set bucket = new HashSet<>(); try { - URL url = plugin.getPluginClassLoader().getResource(getExtensionsResource()); + URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource()); if (url != null) { log.debug("Read '{}'", url.getFile()); Reader reader = new InputStreamReader(url.openStream(), "UTF-8"); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java index c2f81df..b231ffd 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java @@ -129,6 +129,11 @@ public class PluginClassLoader extends URLClassLoader { return super.getResource(name); } + @Override + public URL findResource(String name) { + return super.findResource(name); + } + /** * Release all resources acquired by this class loader. * The current implementation is incomplete. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java index e6501eb..05c9cb4 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java @@ -48,7 +48,6 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { @Override public Map> readClasspathStorages() { log.debug("Reading extensions storages from classpath"); - Map> result = new LinkedHashMap<>(); Set bucket = new HashSet<>(); @@ -85,7 +84,6 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { @Override public Map> readPluginsStorages() { log.debug("Reading extensions storages from plugins"); - Map> result = new LinkedHashMap<>(); List plugins = pluginManager.getPlugins(); @@ -95,7 +93,7 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { Set bucket = new HashSet<>(); try { - URL url = plugin.getPluginClassLoader().getResource(getExtensionsResource()); + URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource()); if (url != null) { File[] files = new File(url.toURI()).listFiles(); if (files != null) {