89 lines
3.1 KiB
Java
89 lines
3.1 KiB
Java
/*
|
|
* Copyright (C) 2024 johan@nosd.in
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the Server Side Public License, version 1,
|
|
* as published by MongoDB, Inc.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* Server Side Public License for more details.
|
|
*
|
|
* You should have received a copy of the Server Side Public License
|
|
* along with this program. If not, see
|
|
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
|
*/
|
|
package in.nosd.redis;
|
|
|
|
|
|
import org.graylog.plugins.pipelineprocessor.ast.functions.Function;
|
|
import org.graylog2.plugin.PluginConfigBean;
|
|
import org.graylog2.plugin.PluginModule;
|
|
|
|
import com.google.inject.multibindings.MapBinder;
|
|
import com.google.inject.Binder;
|
|
import com.google.inject.TypeLiteral;
|
|
|
|
import in.nosd.redis.dataadapters.RedisLookupDataAdapter;
|
|
import in.nosd.redis.functions.RedisLookupPluginFunction;
|
|
|
|
import java.util.Collections;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* Extend the PluginModule abstract class here to add you plugin to the system.
|
|
*/
|
|
public class RedisLookupModule extends PluginModule {
|
|
/**
|
|
* Returns all configuration beans required by this plugin.
|
|
*
|
|
* Implementing this method is optional. The default method returns an empty {@link Set}.
|
|
*/
|
|
@Override
|
|
public Set<? extends PluginConfigBean> getConfigBeans() {
|
|
return Collections.emptySet();
|
|
}
|
|
|
|
@Override
|
|
protected void configure() {
|
|
/*
|
|
* 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();
|
|
*/
|
|
|
|
addMessageProcessorFunction(RedisLookupPluginFunction.NAME, RedisLookupPluginFunction.class);
|
|
|
|
installLookupDataAdapter2(RedisLookupDataAdapter.NAME, RedisLookupDataAdapter.class,
|
|
RedisLookupDataAdapter.Factory.class, RedisLookupDataAdapter.Config.class);
|
|
|
|
addConfigBeans();
|
|
}
|
|
|
|
private void addMessageProcessorFunction(String name, Class<? extends Function<?>> functionClass) {
|
|
addMessageProcessorFunction(binder(), name, functionClass);
|
|
}
|
|
|
|
private MapBinder<String, Function<?>> processorFunctionBinder(Binder binder) {
|
|
return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), new TypeLiteral<Function<?>>() {});
|
|
}
|
|
|
|
private void addMessageProcessorFunction(Binder binder, String name, Class<? extends Function<?>> functionClass) {
|
|
processorFunctionBinder(binder).addBinding(name).to(functionClass);
|
|
}
|
|
}
|