graylog-labs / graylog-plugin-archetype

[DEPRECATED] Maven archetype to write Graylog2 plugins
GNU General Public License v3.0
1 stars 1 forks source link

Plugin archetype v1.0.0-rc1 does work for factories when using addMessageOutput #2

Closed dfch closed 9 years ago

dfch commented 9 years ago

The comments in the plugin archetype for v1.0.0-rc1 (latest release for v1x) suggests to use addMessageOutput as you can see here (quoted from archetype):

/*
 * Register your plugin types here.
 *
 * Examples:
 *
 * addMessageInput(Class<? extends MessageInput>);
 * addMessageFilter(Class<? extends MessageFilter>);
 * addMessageOutput(Class<? extends MessageOutput>);
 * addPeriodical(Class<? extends Periodical>);
 * addAlarmCallback(Class<? extends AlarmCallback>);
 * addInitializer(Class<? extends Service>);
 * addRestResource(Class<? extends PluginRestResource>);
 *
 *
 * Add all configuration beans returned by getConfigBeans():
 *
 * addConfigBeans();
 */

However, when using a factory to instantiate the plugin, this will not work. Instead we have to use

final MapBinder<String, MessageOutput.Factory<? extends MessageOutput>> outputMapBinder = outputsMapBinder();
installOutput(outputMapBinder, dfchOutput.class, dfchOutput.Factory.class);

I know this is not a real issue (but maybe lack of documentation), but my questions is actually, which is the correct way to instantiate an output plugin? The riemann output plugin uses the installOutput method and has been rebuilt for v1.x.

So either the archetype should be updated or it should be better pointed out, what to use in which scenario.

Thanks, Ronald

joschi commented 9 years ago

Unfortunately there seems to be a delay until the graylog-plugin-archetype 1.0.0 is listed in the archetype catalog (http://repo1.maven.org/maven2/archetype-catalog.xml). Version 1.0.0-rc.1 is still referring to an older version of Graylog.

Please verify that the generated plugin skeleton is using Graylog 1.0.0 (org.graylog2:graylog2-plugin:1.0.0) and not an earlier release candidate.

The change for those helper methods in PluginModule has been introduced in Graylog2/graylog2-server@18e42b14a7fdd8262211bf01c51b7dfcd712bb40. We recommend using the "simple" helper method PluginModule#addOutput(Class<? extends MessageOutput>) (and annotating the Factory class accordingly) or Class<T>,Class<? extends MessageOutput.Factory<T>>) (for providing the Factory class explicitly).

joschi commented 9 years ago

You can force the correct version of the Maven archetype with the following command:

mvn archetype:generate -DarchetypeGroupId=org.graylog -DarchetypeArtifactId=graylog-plugin-archetype -DarchetypeVersion=1.0.0
dfch commented 9 years ago

Thanks for the quick reply! So to recap correctly: installOutput is deprecated and should not be used. Then we can close this issue. Thanks again! Ronald

joschi commented 9 years ago

It's not exactly deprecated and won't be removed anytime soon, but it's exposing too much internals that people usually don't want or need to know. I'd recommend using the simpler helper methods whenever possible.