Skip to content

Commit

Permalink
Bump pf4j from 2.5.0 to 3.0.1 (#113)
Browse files Browse the repository at this point in the history
* Bump pf4j from 2.5.0 to 3.0.1

Bumps [pf4j](https://github.com/pf4j/pf4j) from 2.5.0 to 3.0.1.
- [Release notes](https://github.com/pf4j/pf4j/releases)
- [Changelog](https://github.com/pf4j/pf4j/blob/master/CHANGELOG.md)
- [Commits](pf4j/pf4j@release-2.5.0...release-3.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* update code

* simplify `LiiklusPluginLoader`
  • Loading branch information
dependabot-preview[bot] authored and bsideup committed Jul 9, 2019
1 parent 28d21ab commit 4f5cfed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,20 @@
import lombok.extern.slf4j.Slf4j;
import org.pf4j.DefaultPluginLoader;
import org.pf4j.PluginClassLoader;
import org.pf4j.PluginClasspath;
import org.pf4j.PluginManager;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

@Slf4j
public class LiiklusPluginLoader extends DefaultPluginLoader {

public LiiklusPluginLoader(PluginManager pluginManager, PluginClasspath pluginClasspath) {
super(pluginManager, pluginClasspath);
public LiiklusPluginLoader(PluginManager pluginManager) {
super(pluginManager);
}

@Override
protected void loadClasses(Path pluginPath, PluginClassLoader pluginClassLoader) {
// Don't load classes, but add plugin's JAR instead
pluginClassLoader.addFile(pluginPath.toFile());
}

@Override
protected void loadJars(Path pluginPath, PluginClassLoader pluginClassLoader) {
try (var jarFileSystem = FileSystems.newFileSystem(pluginPath, null)) {
for (var libDirectory : this.pluginClasspath.getLibDirectories()) {
var libPath = jarFileSystem.getPath(libDirectory);
if (Files.exists(libPath)) {
try (var pathStream = Files.walk(libPath, 1)) {
pathStream.filter(Files::isRegularFile).forEach(it -> {
try {
var tempFile = Files.createTempFile(it.getFileName().toString(), ".jar");
Files.copy(it, tempFile, StandardCopyOption.REPLACE_EXISTING);
pluginClassLoader.addURL(tempFile.toUri().toURL());
} catch (Exception e) {
log.error("Failed to add file from {}", it.toAbsolutePath(), e);
}
});
}
}
}
} catch (IOException e) {
log.error("Failed to load JARs from {}", pluginPath.toAbsolutePath(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import org.pf4j.ServiceProviderExtensionFinder;

import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

public class LiiklusPluginManager extends DefaultPluginManager {

Expand All @@ -34,11 +37,18 @@ protected PluginRepository createPluginRepository() {

@Override
protected ExtensionFinder createExtensionFinder() {
return new ServiceProviderExtensionFinder(this);
return new ServiceProviderExtensionFinder(this) {
@Override
public Map<String, Set<String>> readClasspathStorages() {
// Loads too much (including some javax.servlet.ServletContainerInitializer classes)
// Since the main jar does not provide any extensions anyways, we can return an empty map here)
return Collections.emptyMap();
}
};
}

@Override
protected PluginLoader createPluginLoader() {
return new LiiklusPluginLoader(this, pluginClasspath);
return new LiiklusPluginLoader(this);
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ configure(subprojects.findAll { !it.name.startsWith("examples/") }) {
dependencies {
dependency 'org.projectlombok:lombok:1.18.8'

dependency 'org.pf4j:pf4j:2.5.0'
dependency 'org.pf4j:pf4j:3.0.1'

dependencySet(group: 'io.rsocket', version: '0.11.16') {
entry 'rsocket-transport-netty'
Expand Down

0 comments on commit 4f5cfed

Please sign in to comment.