
org.meridor.stecker.impl.DefaultPluginsProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stecker-plugin-loader Show documentation
Show all versions of stecker-plugin-loader Show documentation
This is a plugin loading library. Its main purpose is to load extension point implementations from
provided plugins.
package org.meridor.stecker.impl;
import org.meridor.stecker.PluginException;
import org.meridor.stecker.interfaces.PluginsProvider;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.List;
import java.util.stream.Collectors;
public class DefaultPluginsProvider implements PluginsProvider {
private final String fileGlob;
public DefaultPluginsProvider(String fileGlob) {
this.fileGlob = fileGlob;
}
@Override
public List provide(Path pluginsDirectory) throws PluginException {
try {
PathMatcher pathMatcher = FileSystems
.getDefault()
.getPathMatcher("glob:" + fileGlob);
return Files.list(pluginsDirectory)
.filter(pathMatcher::matches)
.filter(Files::isRegularFile)
.collect(Collectors.toList());
} catch (IOException e) {
throw new PluginException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy