aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main/java/com/yahoo/jdisc/service/AbstractServerProvider.java
blob: 6966a50d5399b07e99b4a74b21ea7a5ef25cf874 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.service;

import com.google.inject.Inject;
import com.yahoo.jdisc.AbstractResource;
import com.yahoo.jdisc.Request;

import java.util.Objects;

/**
 * <p>This is a convenient parent class for {@link ServerProvider} with default implementations for all but the
 * essential {@link #start()} and {@link #close()} methods. It requires that the {@link CurrentContainer} is injected in
 * the constructor, since that interface is needed to dispatch {@link Request}s.</p>
 *
 * @author Simon Thoresen Hult
 */
public abstract class AbstractServerProvider extends AbstractResource implements ServerProvider {

    private final CurrentContainer container;

    @Inject
    protected AbstractServerProvider(CurrentContainer container) {
        Objects.requireNonNull(container, "container");
        this.container = container;
    }

    public final CurrentContainer container() {
        return container;
    }
}