aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationEnvironmentModule.java
blob: 43f45186f2078bfda26bb380488274028daed355 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.core;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.yahoo.jdisc.application.ContainerActivator;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.application.ContainerThread;
import com.yahoo.jdisc.application.OsgiFramework;
import com.yahoo.jdisc.service.CurrentContainer;
import com.yahoo.jdisc.statistics.ContainerWatchdogMetrics;

import java.util.concurrent.ThreadFactory;

/**
 * @author Simon Thoresen Hult
 */
class ApplicationEnvironmentModule extends AbstractModule {

    private final ApplicationLoader loader;

    public ApplicationEnvironmentModule(ApplicationLoader loader) {
        this.loader = loader;
    }

    @Override
    protected void configure() {
        bind(ContainerActivator.class).toInstance(loader);
        bind(CurrentContainer.class).toInstance(loader);
        bind(OsgiFramework.class).toInstance(loader.osgiFramework());
        bind(ThreadFactory.class).to(ContainerThread.Factory.class);
        bind(ContainerWatchdogMetrics.class).toInstance(loader.getContainerWatchdogMetrics());
    }

    @Provides
    public ContainerBuilder containerBuilder() {
        return loader.newContainerBuilder();
    }
}