/* * 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 * . */ 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 getConfigBeans() { return Collections.emptySet(); } @Override protected void configure() { /* * Register your plugin types here. * * Examples: * * addMessageInput(Class); * addMessageFilter(Class); * addMessageOutput(Class); * addPeriodical(Class); // * addAlarmCallback(Class); * addInitializer(Class); * addRestResource(Class); * * * 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> functionClass) { addMessageProcessorFunction(binder(), name, functionClass); } private MapBinder> processorFunctionBinder(Binder binder) { return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), new TypeLiteral>() {}); } private void addMessageProcessorFunction(Binder binder, String name, Class> functionClass) { processorFunctionBinder(binder).addBinding(name).to(functionClass); } }