From ec60800452476fd9019e6eabd3d20b1bdb5528ca Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Tue, 5 Jan 2016 15:21:52 +0200 Subject: Use PluginClassLoader.findResource instead of getResource --- pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java | 4 +--- pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java | 5 +++++ .../main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'pf4j') 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) { -- cgit v1.2.3