aboutsummaryrefslogtreecommitdiffstats
path: root/container-disc/src/main/java/com/yahoo/container/jdisc/metric/MetricProvider.java
blob: b547b3dd897c7e754a6abaeab40d9ff8c590de88 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.metric;

import com.yahoo.container.di.componentgraph.Provider;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.application.MetricConsumer;

/**
 * An implementation of {@link Provider} component of <code>Metric</code>. Because this class depends on {@link
 * MetricConsumerProvider}, any change to the consumer configuration will trigger reconfiguration of this component,
 * which in turn triggers reconfiguration of any component that depends on <code>Metric</code>.
 *
 * @author Simon Thoresen Hult
 */
public final class MetricProvider implements Provider<Metric> {

    private final Metric metric;

    public MetricProvider(MetricConsumerProvider provider) {
        metric = new com.yahoo.jdisc.application.MetricProvider(new com.google.inject.Provider<MetricConsumer>() {

            @Override
            public MetricConsumer get() {
                return provider.newInstance();
            }
        }).get();
    }

    @Override
    public Metric get() {
        return metric;
    }

    @Override
    public void deconstruct() { }

}