From 8251a506676b9dd27e035a0867e128aaedde7cb3 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 5 Jan 2016 17:12:53 +0100 Subject: [PATCH] make ProcessorFactoryProvider extend BiFunction --- .../ingest/ProcessorFactoryProvider.java | 14 +++++++------- .../elasticsearch/plugin/ingest/PipelineStore.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java b/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java index e1126b305b1..efecf11d0b8 100644 --- a/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java +++ b/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java @@ -21,14 +21,14 @@ package org.elasticsearch.ingest; import org.elasticsearch.env.Environment; +import java.util.function.BiFunction; + /** - * The ingest framework (pipeline, processor and processor factory) can't rely on ES specific code. However some - * processors rely on reading files from the config directory. We can't add Environment as a constructor parameter, - * so we need some code that provides the physical location of the configuration directory to the processor factories - * that need this and this is what this processor factory provider does. + * Functional interface that allows to create a {@link org.elasticsearch.ingest.Processor.Factory} once all the needed + * components are available at a later stage, more specifically the {@link Environment} and the {@link TemplateService} + * which some processors need. */ -//TODO this abstraction could be removed once ingest-core is part of es core? @FunctionalInterface -public interface ProcessorFactoryProvider { - Processor.Factory get(Environment environment, TemplateService templateService); +public interface ProcessorFactoryProvider extends BiFunction { + } diff --git a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/PipelineStore.java b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/PipelineStore.java index 5e5276044de..32a1973c113 100644 --- a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/PipelineStore.java +++ b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/PipelineStore.java @@ -89,7 +89,7 @@ public class PipelineStore extends AbstractComponent implements Closeable { Map processorFactories = new HashMap<>(); TemplateService templateService = new MustacheTemplateService(scriptService); for (Map.Entry entry : processorFactoryProviders.entrySet()) { - Processor.Factory processorFactory = entry.getValue().get(environment, templateService); + Processor.Factory processorFactory = entry.getValue().apply(environment, templateService); processorFactories.put(entry.getKey(), processorFactory); } this.processorFactoryRegistry = Collections.unmodifiableMap(processorFactories);