Search in sources :

Example 1 with PluginModule

use of org.graylog2.plugin.PluginModule in project graylog2-server by Graylog2.

the class PluginBindings method configure.

@Override
protected void configure() {
    final Multibinder<Plugin> pluginbinder = Multibinder.newSetBinder(binder(), Plugin.class);
    final Multibinder<PluginMetaData> pluginMetaDataBinder = Multibinder.newSetBinder(binder(), PluginMetaData.class);
    // Make sure there is a binding for the plugin rest resource classes to avoid binding errors when running
    // without plugins.
    MapBinder.newMapBinder(binder(), new TypeLiteral<String>() {
    }, new TypeLiteral<Class<? extends PluginRestResource>>() {
    }).permitDuplicates();
    // Make sure there is a binding for the PluginUISettingsProvider classes to avoid binding errors when running
    // without plugins
    MapBinder.newMapBinder(binder(), String.class, PluginUISettingsProvider.class).permitDuplicates();
    for (final Plugin plugin : plugins) {
        pluginbinder.addBinding().toInstance(plugin);
        for (final PluginModule pluginModule : plugin.modules()) {
            binder().install(pluginModule);
        }
        pluginMetaDataBinder.addBinding().toInstance(plugin.metadata());
    }
}
Also used : TypeLiteral(com.google.inject.TypeLiteral) PluginUISettingsProvider(org.graylog2.web.PluginUISettingsProvider) PluginMetaData(org.graylog2.plugin.PluginMetaData) PluginModule(org.graylog2.plugin.PluginModule) Plugin(org.graylog2.plugin.Plugin)

Example 2 with PluginModule

use of org.graylog2.plugin.PluginModule in project graylog2-server by Graylog2.

the class CmdLineTool method installPluginConfigAndBindings.

private PluginBindings installPluginConfigAndBindings(String pluginPath, ChainingClassLoader classLoader) {
    final Set<Plugin> plugins = loadPlugins(pluginPath, classLoader);
    final PluginBindings pluginBindings = new PluginBindings(plugins);
    for (final Plugin plugin : plugins) {
        for (final PluginModule pluginModule : plugin.modules()) {
            for (final PluginConfigBean configBean : pluginModule.getConfigBeans()) {
                jadConfig.addConfigurationBean(configBean);
            }
        }
    }
    return pluginBindings;
}
Also used : PluginConfigBean(org.graylog2.plugin.PluginConfigBean) PluginBindings(org.graylog2.shared.bindings.PluginBindings) PluginModule(org.graylog2.plugin.PluginModule) Plugin(org.graylog2.plugin.Plugin)

Aggregations

Plugin (org.graylog2.plugin.Plugin)2 PluginModule (org.graylog2.plugin.PluginModule)2 TypeLiteral (com.google.inject.TypeLiteral)1 PluginConfigBean (org.graylog2.plugin.PluginConfigBean)1 PluginMetaData (org.graylog2.plugin.PluginMetaData)1 PluginBindings (org.graylog2.shared.bindings.PluginBindings)1 PluginUISettingsProvider (org.graylog2.web.PluginUISettingsProvider)1