aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/container/docproc/MbusClient.java
blob: 9314c66ced7c64f6d49495d75b60a2d2982654cd (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
36
37
38
39
40
41
42
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.docproc;

import com.yahoo.component.ComponentId;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.container.jdisc.config.SessionConfig;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.Handler;

/**
 * @author Einar M R Rosenvinge
 */
public class MbusClient extends Handler implements SessionConfig.Producer {
    private static final ComponentSpecification CLASSNAME =
            ComponentSpecification.fromString("com.yahoo.container.jdisc.messagebus.MbusClientProvider");

    private final String sessionName;
    private final SessionConfig.Type.Enum type;

    public MbusClient(String sessionName, SessionConfig.Type.Enum type) {
        super(new ComponentModel(new BundleInstantiationSpecification(createId(sessionName), CLASSNAME, null)));
        this.sessionName = sessionName;
        this.type = type;
    }

    private static ComponentId createId(String sessionName) {
        return ComponentId.fromString(sessionName).nestInNamespace(
                ComponentId.fromString("MbusClient"));
    }

    @Override
    public void getConfig(SessionConfig.Builder sb) {
        sb.
            name(sessionName).
            type(type);
    }
    
    public String getSessionName() {
        return sessionName;
    }
}