diff options
author | Sebastian Lövdahl <slovdahl@hibox.fi> | 2019-09-04 12:45:07 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2019-09-04 12:45:07 +0300 |
commit | 628bc9d92d483aef7318d02df97ca33d897de8ca (patch) | |
tree | 9db8cf68f402ecff29295d3985c27a4fb641d91a /pf4j/src/main/java/org | |
parent | f66859f71c0e9c043a14ca32f26b459de54317aa (diff) | |
download | pf4j-628bc9d92d483aef7318d02df97ca33d897de8ca.tar.gz pf4j-628bc9d92d483aef7318d02df97ca33d897de8ca.zip |
Implement PluginClassLoader.getResources (#336) (#337)
Diffstat (limited to 'pf4j/src/main/java/org')
-rw-r--r-- | pf4j/src/main/java/org/pf4j/PluginClassLoader.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pf4j/src/main/java/org/pf4j/PluginClassLoader.java b/pf4j/src/main/java/org/pf4j/PluginClassLoader.java index 022b61c..755921a 100644 --- a/pf4j/src/main/java/org/pf4j/PluginClassLoader.java +++ b/pf4j/src/main/java/org/pf4j/PluginClassLoader.java @@ -22,6 +22,9 @@ import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; import java.util.List; /** @@ -189,6 +192,23 @@ public class PluginClassLoader extends URLClassLoader { } } + @Override + public Enumeration<URL> getResources(String name) throws IOException { + if (!parentFirst) { + List<URL> resources = new ArrayList<>(); + + resources.addAll(Collections.list(findResources(name))); + + if (getParent() != null) { + resources.addAll(Collections.list(getParent().getResources(name))); + } + + return Collections.enumeration(resources); + } else { + return super.getResources(name); + } + } + private Class<?> loadClassFromDependencies(String className) { log.trace("Search in dependencies for class '{}'", className); List<PluginDependency> dependencies = pluginDescriptor.getDependencies(); |