use of com.amazon.dataprepper.model.annotations.DataPrepperPlugin in project data-prepper by opensearch-project.
the class ClasspathPluginProvider method scanForPlugins.
private Map<String, Map<Class<?>, Class<?>>> scanForPlugins() {
final Set<Class<?>> dataPrepperPluginClasses = reflections.getTypesAnnotatedWith(DataPrepperPlugin.class);
final Map<String, Map<Class<?>, Class<?>>> pluginsMap = new HashMap<>(dataPrepperPluginClasses.size());
for (final Class<?> concretePluginClass : dataPrepperPluginClasses) {
final DataPrepperPlugin dataPrepperPluginAnnotation = concretePluginClass.getAnnotation(DataPrepperPlugin.class);
final String pluginName = dataPrepperPluginAnnotation.name();
Class<?> supportedType = dataPrepperPluginAnnotation.pluginType();
if (supportedType.equals(Void.class)) {
supportedType = dataPrepperPluginAnnotation.type().pluginClass();
}
final Map<Class<?>, Class<?>> supportTypeToPluginTypeMap = pluginsMap.computeIfAbsent(pluginName, k -> new HashMap<>());
supportTypeToPluginTypeMap.put(supportedType, concretePluginClass);
}
return pluginsMap;
}
use of com.amazon.dataprepper.model.annotations.DataPrepperPlugin in project data-prepper by opensearch-project.
the class DefaultPluginFactory method getConstructionContext.
private <T> PluginArgumentsContext getConstructionContext(final PluginSetting pluginSetting, final Class<? extends T> pluginClass) {
final DataPrepperPlugin pluginAnnotation = pluginClass.getAnnotation(DataPrepperPlugin.class);
final Class<?> pluginConfigurationType = pluginAnnotation.pluginConfigurationType();
final Object configuration = pluginConfigurationConverter.convert(pluginConfigurationType, pluginSetting);
return new PluginArgumentsContext.Builder().withPluginSetting(pluginSetting).withPluginConfiguration(configuration).withPluginFactory(this).withBeanFactory(pluginBeanFactoryProvider.get()).build();
}
use of com.amazon.dataprepper.model.annotations.DataPrepperPlugin 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;
}
}
}
Aggregations