Browse Source

Use PluginClassLoader.findResource instead of getResource

pull/85/head
Decebal Suiu 9 years ago
parent
commit
ec60800452
  1. 4
      pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java
  2. 5
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java
  3. 4
      pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java

4
pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java

@ -47,7 +47,6 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder {
@Override @Override
public Map<String, Set<String>> readClasspathStorages() { public Map<String, Set<String>> readClasspathStorages() {
log.debug("Reading extensions storages from classpath"); log.debug("Reading extensions storages from classpath");
Map<String, Set<String>> result = new LinkedHashMap<>(); Map<String, Set<String>> result = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>(); Set<String> bucket = new HashSet<>();
@ -80,7 +79,6 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder {
@Override @Override
public Map<String, Set<String>> readPluginsStorages() { public Map<String, Set<String>> readPluginsStorages() {
log.debug("Reading extensions storages from plugins"); log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>(); Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins(); List<PluginWrapper> plugins = pluginManager.getPlugins();
@ -90,7 +88,7 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder {
Set<String> bucket = new HashSet<>(); Set<String> bucket = new HashSet<>();
try { try {
URL url = plugin.getPluginClassLoader().getResource(getExtensionsResource()); URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource());
if (url != null) { if (url != null) {
log.debug("Read '{}'", url.getFile()); log.debug("Read '{}'", url.getFile());
Reader reader = new InputStreamReader(url.openStream(), "UTF-8"); Reader reader = new InputStreamReader(url.openStream(), "UTF-8");

5
pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java

@ -129,6 +129,11 @@ public class PluginClassLoader extends URLClassLoader {
return super.getResource(name); return super.getResource(name);
} }
@Override
public URL findResource(String name) {
return super.findResource(name);
}
/** /**
* Release all resources acquired by this class loader. * Release all resources acquired by this class loader.
* The current implementation is incomplete. * The current implementation is incomplete.

4
pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java

@ -48,7 +48,6 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder {
@Override @Override
public Map<String, Set<String>> readClasspathStorages() { public Map<String, Set<String>> readClasspathStorages() {
log.debug("Reading extensions storages from classpath"); log.debug("Reading extensions storages from classpath");
Map<String, Set<String>> result = new LinkedHashMap<>(); Map<String, Set<String>> result = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>(); Set<String> bucket = new HashSet<>();
@ -85,7 +84,6 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder {
@Override @Override
public Map<String, Set<String>> readPluginsStorages() { public Map<String, Set<String>> readPluginsStorages() {
log.debug("Reading extensions storages from plugins"); log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>(); Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins(); List<PluginWrapper> plugins = pluginManager.getPlugins();
@ -95,7 +93,7 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder {
Set<String> bucket = new HashSet<>(); Set<String> bucket = new HashSet<>();
try { try {
URL url = plugin.getPluginClassLoader().getResource(getExtensionsResource()); URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource());
if (url != null) { if (url != null) {
File[] files = new File(url.toURI()).listFiles(); File[] files = new File(url.toURI()).listFiles();
if (files != null) { if (files != null) {

Loading…
Cancel
Save