Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "URI is not hierarchical" issue #89

Merged
merged 2 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Class<?> loadClass(String className) throws ClassNotFoundException {
}
}

log.debug("Couldn't find class '{}' in plugin classpath. Delegating to parent");
log.debug("Couldn't find class '{}' in plugin classpath. Delegating to parent", className);

// use the standard URLClassLoader (which follows normal parent delegation)
return super.loadClass(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.slf4j.LoggerFactory;
import ro.fortsoft.pf4j.processor.ServiceProviderExtensionStorage;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -111,19 +109,29 @@ public Map<String, Set<String>> readPluginsStorages() {
for (PluginWrapper plugin : plugins) {
String pluginId = plugin.getDescriptor().getPluginId();
log.debug("Reading extensions storages for plugin '{}'", pluginId);
Set<String> bucket = new HashSet<>();
final Set<String> bucket = new HashSet<>();

try {
URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource());
if (url != null) {
File[] files = new File(url.toURI()).listFiles();
if (files != null) {
for (File file : files) {
Path extensionPath;
if (url.toURI().getScheme().equals("jar")) {
FileSystem fileSystem = FileSystems.newFileSystem(url.toURI(), Collections.<String, Object>emptyMap());
extensionPath = fileSystem.getPath(getExtensionsResource());
} else {
extensionPath = Paths.get(url.toURI());
}
Files.walkFileTree(extensionPath, Collections.<FileVisitOption>emptySet(), 1, new SimpleFileVisitor<Path>() {

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
log.debug("Read '{}'", file);
Reader reader = new FileReader(file);
Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8);
ServiceProviderExtensionStorage.read(reader, bucket);
return FileVisitResult.CONTINUE;
}
}

});
} else {
log.debug("Cannot find '{}'", getExtensionsResource());
}
Expand Down