Search in sources :

Example 1 with PluginLoader

use of org.graylog2.shared.plugins.PluginLoader in project graylog2-server by Graylog2.

the class CmdLineTool method loadPlugins.

protected Set<Plugin> loadPlugins(String pluginPath, ChainingClassLoader chainingClassLoader) {
    final File pluginDir = new File(pluginPath);
    final Set<Plugin> plugins = new HashSet<>();
    final PluginLoader pluginLoader = new PluginLoader(pluginDir, chainingClassLoader);
    for (Plugin plugin : pluginLoader.loadPlugins()) {
        final PluginMetaData metadata = plugin.metadata();
        if (capabilities().containsAll(metadata.getRequiredCapabilities())) {
            if (version.sameOrHigher(metadata.getRequiredVersion())) {
                LOG.info("Loaded plugin: {}", plugin);
                plugins.add(plugin);
            } else {
                LOG.error("Plugin \"" + metadata.getName() + "\" requires version " + metadata.getRequiredVersion() + " - not loading!");
            }
        } else {
            LOG.debug("Skipping plugin \"{}\" because some capabilities are missing ({}).", metadata.getName(), Sets.difference(plugin.metadata().getRequiredCapabilities(), capabilities()));
        }
    }
    return plugins;
}
Also used : PluginMetaData(org.graylog2.plugin.PluginMetaData) File(java.io.File) PluginLoader(org.graylog2.shared.plugins.PluginLoader) HashSet(java.util.HashSet) Plugin(org.graylog2.plugin.Plugin)

Example 2 with PluginLoader

use of org.graylog2.shared.plugins.PluginLoader in project graylog2-server by Graylog2.

the class CmdLineTool method loadPlugins.

protected Set<Plugin> loadPlugins(Path pluginPath, ChainingClassLoader chainingClassLoader) {
    final Set<Plugin> plugins = new HashSet<>();
    final PluginLoader pluginLoader = new PluginLoader(pluginPath.toFile(), chainingClassLoader, coreConfigInjector);
    for (Plugin plugin : pluginLoader.loadPlugins()) {
        final PluginMetaData metadata = plugin.metadata();
        if (capabilities().containsAll(metadata.getRequiredCapabilities())) {
            if (version.sameOrHigher(metadata.getRequiredVersion())) {
                LOG.info("Loaded plugin: {}", plugin);
                plugins.add(plugin);
            } else {
                LOG.error("Plugin \"" + metadata.getName() + "\" requires version " + metadata.getRequiredVersion() + " - not loading!");
            }
        } else {
            LOG.debug("Skipping plugin \"{}\" because some capabilities are missing ({}).", metadata.getName(), Sets.difference(plugin.metadata().getRequiredCapabilities(), capabilities()));
        }
    }
    return plugins;
}
Also used : PluginMetaData(org.graylog2.plugin.PluginMetaData) PluginLoader(org.graylog2.shared.plugins.PluginLoader) Plugin(org.graylog2.plugin.Plugin) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 Plugin (org.graylog2.plugin.Plugin)2 PluginMetaData (org.graylog2.plugin.PluginMetaData)2 PluginLoader (org.graylog2.shared.plugins.PluginLoader)2 File (java.io.File)1