Search in sources :

Example 1 with PluginRestResource

use of org.graylog2.plugin.rest.PluginRestResource 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();
    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) PluginMetaData(org.graylog2.plugin.PluginMetaData) PluginModule(org.graylog2.plugin.PluginModule) Plugin(org.graylog2.plugin.Plugin)

Aggregations

TypeLiteral (com.google.inject.TypeLiteral)1 Plugin (org.graylog2.plugin.Plugin)1 PluginMetaData (org.graylog2.plugin.PluginMetaData)1 PluginModule (org.graylog2.plugin.PluginModule)1