Search in sources :

Example 1 with PluginType

use of com.amazon.dataprepper.model.PluginType in project data-prepper by opensearch-project.

the class PluginRepository method findPlugins.

private static void findPlugins() {
    final Reflections reflections = new Reflections(DEFAULT_PLUGINS_CLASSPATH);
    final Set<Class<?>> annotatedClasses = reflections.getTypesAnnotatedWith(DataPrepperPlugin.class);
    for (final Class<?> annotatedClass : annotatedClasses) {
        final DataPrepperPlugin dataPrepperPluginAnnotation = annotatedClass.getAnnotation(DataPrepperPlugin.class);
        final String pluginName = dataPrepperPluginAnnotation.name();
        final PluginType pluginType = extractPluginType(dataPrepperPluginAnnotation);
        switch(pluginType) {
            case SOURCE:
                SOURCES.put(pluginName, (Class<Source>) annotatedClass);
                break;
            case BUFFER:
                BUFFERS.put(pluginName, (Class<Buffer>) annotatedClass);
                break;
            case PREPPER:
                PROCESSORS.put(pluginName, (Class<Processor>) annotatedClass);
                break;
            case SINK:
                SINKS.put(pluginName, (Class<Sink>) annotatedClass);
                break;
        }
    }
}
Also used : Buffer(com.amazon.dataprepper.model.buffer.Buffer) Processor(com.amazon.dataprepper.model.processor.Processor) DataPrepperPlugin(com.amazon.dataprepper.model.annotations.DataPrepperPlugin) Sink(com.amazon.dataprepper.model.sink.Sink) PluginType(com.amazon.dataprepper.model.PluginType) Source(com.amazon.dataprepper.model.source.Source) Reflections(org.reflections.Reflections)

Aggregations

PluginType (com.amazon.dataprepper.model.PluginType)1 DataPrepperPlugin (com.amazon.dataprepper.model.annotations.DataPrepperPlugin)1 Buffer (com.amazon.dataprepper.model.buffer.Buffer)1 Processor (com.amazon.dataprepper.model.processor.Processor)1 Sink (com.amazon.dataprepper.model.sink.Sink)1 Source (com.amazon.dataprepper.model.source.Source)1 Reflections (org.reflections.Reflections)1