aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/GenericChainedComponentModelBuilder.java
blob: 17382c3ab40c982fa3a3b22d1e239dbe88f26818 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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.ComponentSpecification;
import com.yahoo.component.chain.dependencies.Dependencies;
import com.yahoo.component.chain.model.ChainedComponentModel;
import com.yahoo.config.model.builder.xml.XmlHelper;
import org.w3c.dom.Element;

/**
 * reads the common attributes and elements of all chained component elements.
 * @author Tony Vaagenes
 */
public abstract class GenericChainedComponentModelBuilder {
    //The componentId might be used as a spec later(for example as class or
    //bundle), so we must treat it as a specification until then.
    protected final ComponentSpecification componentId;
    protected final Dependencies dependencies;

    public GenericChainedComponentModelBuilder(Element spec) {
        componentId = readComponentId(spec);
        dependencies = readDependencies(spec);
    }

    private Dependencies readDependencies(Element spec) {
        return new DependenciesBuilder(spec).build();
    }

    protected ComponentSpecification readComponentId(Element spec) {
        return XmlHelper.getIdRef(spec);
    }

    protected abstract ChainedComponentModel build();

}