com.yahoo.vespa.model.builder.xml.dom.chains.DomChainBuilderBase Maven / Gradle / Ivy
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.builder.xml.dom.chains;
import com.yahoo.component.chain.model.ChainSpecification;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AnyConfigProducer;
import com.yahoo.config.model.producer.TreeConfigProducer;
import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder;
import com.yahoo.vespa.model.container.component.chain.Chain;
import com.yahoo.vespa.model.container.component.chain.ChainedComponent;
import org.w3c.dom.Element;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Base functionality for all chain builders (docprocChain, searchChain, provider, source)
* @author Tony Vaagenes
*/
public abstract class DomChainBuilderBase, CHAIN extends Chain>
extends VespaDomBuilder.DomConfigProducerBuilderBase {
private final Collection> allowedComponentTypes;
protected final Map> outerComponentTypeByComponentName;
public DomChainBuilderBase(Collection> allowedComponentTypes,
Map> outerComponentTypeByComponentName) {
this.allowedComponentTypes = allowedComponentTypes;
this.outerComponentTypeByComponentName = outerComponentTypeByComponentName;
}
public final CHAIN doBuild(DeployState deployState, TreeConfigProducer ancestor, Element producerSpec) {
ComponentsBuilder componentsBuilder =
new ComponentsBuilder<>(deployState, ancestor, allowedComponentTypes, List.of(producerSpec), outerComponentTypeByComponentName);
ChainSpecification specWithoutInnerComponents =
new ChainSpecificationBuilder(producerSpec).build(componentsBuilder.getOuterComponentReferences());
CHAIN chain = buildChain(deployState, ancestor, producerSpec, specWithoutInnerComponents);
addInnerComponents(chain, componentsBuilder.getComponentDefinitions());
return chain;
}
private void addInnerComponents(CHAIN chain, Collection componentDefinitions) {
for (COMPONENT innerComponent : componentDefinitions) {
chain.addInnerComponent(innerComponent);
}
}
protected abstract CHAIN buildChain(DeployState deployState, TreeConfigProducer ancestor, Element producerSpec,
ChainSpecification specWithoutInnerComponents);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy