aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core_test/test_bundles/my-server-provider/src/main/java/com/yahoo/jdisc/bundle/MyServerProvider.java
blob: 37b8cdcd4ec1c67ed5db49f0a065a8e711674b48 (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
43
44
45
46
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.bundle;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.yahoo.jdisc.AbstractResource;
import com.yahoo.jdisc.service.ServerProvider;

import java.util.concurrent.CountDownLatch;

/**
 * @author Simon Thoresen Hult
 */
public class MyServerProvider extends AbstractResource implements ServerProvider {

    private final CountDownLatch startLatch;
    private final CountDownLatch closeLatch;
    private final CountDownLatch destroyLatch;

    @Inject
    public MyServerProvider(@Named("Init") CountDownLatch initLatch,
                            @Named("Start") CountDownLatch startLatch,
                            @Named("Close") CountDownLatch closeLatch,
                            @Named("Destroy") CountDownLatch destroyLatch)
    {
        this.startLatch = startLatch;
        this.closeLatch = closeLatch;
        this.destroyLatch = destroyLatch;
        initLatch.countDown();
    }

    @Override
    public void start() {
        startLatch.countDown();
    }

    @Override
    public void close() {
        closeLatch.countDown();
    }

    @Override
    protected void destroy() {
        destroyLatch.countDown();
    }
}