aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/container/component/chain/ChainedComponent.java
blob: 40440f3456b9e2eb93c2c00a5af21f94ea51d1f5 (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 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component.chain;

import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.model.ChainedComponentModel;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.container.component.Component;


/**
 * @author Tony Vaagenes
 * @author gjoranv
 *
 * Base class for all ChainedComponent config producers.
 */
public class ChainedComponent<T extends ChainedComponentModel> extends Component<AbstractConfigProducer<?>, T> {

    public ChainedComponent(T model) {
        super(model);
    }

    public void initialize() {}

    @Override
    public ComponentId getGlobalComponentId() {
        return model.getComponentId().nestInNamespace(namespace());
    }

    private ComponentId namespace() {
        AbstractConfigProducer owner = getParent().getParent();
        return (owner instanceof Chain) ?
                ((Chain) owner).getGlobalComponentId() :
                null;
    }
}