diff --git a/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java b/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java deleted file mode 100644 index efecf11d0b8..00000000000 --- a/core/src/main/java/org/elasticsearch/ingest/ProcessorFactoryProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.ingest; - -import org.elasticsearch.env.Environment; - -import java.util.function.BiFunction; - -/** - * 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. - */ -@FunctionalInterface -public interface ProcessorFactoryProvider extends BiFunction { - -} diff --git a/core/src/main/java/org/elasticsearch/ingest/ProcessorsModule.java b/core/src/main/java/org/elasticsearch/ingest/ProcessorsModule.java index 22d5ba92bbc..c56f7c571c4 100644 --- a/core/src/main/java/org/elasticsearch/ingest/ProcessorsModule.java +++ b/core/src/main/java/org/elasticsearch/ingest/ProcessorsModule.java @@ -20,11 +20,13 @@ package org.elasticsearch.ingest; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.env.Environment; + +import java.util.function.BiFunction; /** * Registry for processor factories * @see org.elasticsearch.ingest.Processor.Factory - * @see ProcessorFactoryProvider */ public class ProcessorsModule extends AbstractModule { @@ -42,7 +44,7 @@ public class ProcessorsModule extends AbstractModule { /** * Adds a processor factory under a specific type name. */ - public void addProcessor(String type, ProcessorFactoryProvider processorFactoryProvider) { + public void addProcessor(String type, BiFunction> processorFactoryProvider) { processorsRegistry.addProcessor(type, processorFactoryProvider); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/ProcessorsRegistry.java b/core/src/main/java/org/elasticsearch/ingest/ProcessorsRegistry.java index a9936567592..465d5c5f047 100644 --- a/core/src/main/java/org/elasticsearch/ingest/ProcessorsRegistry.java +++ b/core/src/main/java/org/elasticsearch/ingest/ProcessorsRegistry.java @@ -19,25 +19,28 @@ package org.elasticsearch.ingest; +import org.elasticsearch.env.Environment; + import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.function.BiFunction; public class ProcessorsRegistry { - private final Map processorFactoryProviders = new HashMap<>(); + private final Map>> processorFactoryProviders = new HashMap<>(); /** * Adds a processor factory under a specific name. */ - public void addProcessor(String name, ProcessorFactoryProvider processorFactoryProvider) { - ProcessorFactoryProvider provider = processorFactoryProviders.putIfAbsent(name, processorFactoryProvider); + public void addProcessor(String name, BiFunction> processorFactoryProvider) { + BiFunction> provider = processorFactoryProviders.putIfAbsent(name, processorFactoryProvider); if (provider != null) { throw new IllegalArgumentException("Processor factory already registered for name [" + name + "]"); } } - public Set> entrySet() { + public Set>>> entrySet() { return processorFactoryProviders.entrySet(); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/ProcessorsRegistryTests.java b/core/src/test/java/org/elasticsearch/ingest/ProcessorsRegistryTests.java index 91847a07118..d9a7086412a 100644 --- a/core/src/test/java/org/elasticsearch/ingest/ProcessorsRegistryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/ProcessorsRegistryTests.java @@ -19,10 +19,12 @@ package org.elasticsearch.ingest; +import org.elasticsearch.env.Environment; import org.elasticsearch.test.ESTestCase; import java.util.Map; import java.util.Set; +import java.util.function.BiFunction; import static org.hamcrest.CoreMatchers.equalTo; @@ -42,9 +44,9 @@ public class ProcessorsRegistryTests extends ESTestCase { assertThat(e.getMessage(), equalTo("Processor factory already registered for name [1]")); } - Set> entrySet = processorsRegistry.entrySet(); + Set>>> entrySet = processorsRegistry.entrySet(); assertThat(entrySet.size(), equalTo(2)); - for (Map.Entry entry : entrySet) { + for (Map.Entry>> entry : entrySet) { if (entry.getKey().equals("1")) { assertThat(entry.getValue().apply(null, null), equalTo(factory1)); } else if (entry.getKey().equals("2")) { diff --git a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestBootstrapper.java b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestBootstrapper.java index b13c95a3681..2561638c107 100644 --- a/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestBootstrapper.java +++ b/plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/IngestBootstrapper.java @@ -36,7 +36,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.DiscoverySettings; import org.elasticsearch.env.Environment; import org.elasticsearch.gateway.GatewayService; -import org.elasticsearch.ingest.ProcessorFactoryProvider; import org.elasticsearch.ingest.ProcessorsRegistry; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; @@ -44,7 +43,6 @@ import org.elasticsearch.transport.TransportService; import java.io.IOException; import java.io.InputStream; -import java.util.Map; /** * Instantiates and wires all the services that the ingest plugin will be needing. 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 1f52bd6b41e..633667aaa22 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 @@ -41,10 +41,9 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.ingest.Pipeline; -import org.elasticsearch.ingest.ProcessorFactoryProvider; +import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.ProcessorsRegistry; import org.elasticsearch.ingest.TemplateService; -import org.elasticsearch.ingest.Processor; import org.elasticsearch.plugin.ingest.transport.delete.DeletePipelineRequest; import org.elasticsearch.plugin.ingest.transport.put.PutPipelineRequest; import org.elasticsearch.plugin.ingest.transport.reload.ReloadPipelinesAction; @@ -61,6 +60,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.BiFunction; public class PipelineStore extends AbstractComponent implements Closeable { @@ -89,7 +89,7 @@ public class PipelineStore extends AbstractComponent implements Closeable { public void buildProcessorFactoryRegistry(ProcessorsRegistry processorsRegistry, Environment environment, ScriptService scriptService) { Map processorFactories = new HashMap<>(); TemplateService templateService = new InternalTemplateService(scriptService); - for (Map.Entry entry : processorsRegistry.entrySet()) { + for (Map.Entry>> entry : processorsRegistry.entrySet()) { Processor.Factory processorFactory = entry.getValue().apply(environment, templateService); processorFactories.put(entry.getKey(), processorFactory); }