blob: 0311eedd726e2772bf703eacc22018f29b47aeac (
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
47
48
49
50
51
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.yahoo.container.QrConfig;
import com.yahoo.container.Server;
import com.yahoo.container.jdisc.messagebus.SessionCache;
import com.yahoo.jrt.ListenFailedException;
import com.yahoo.log.LogLevel;
import java.util.logging.Logger;
/**
* The application which sets up the jDisc container
*
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
*/
public class ContainerDiscApplication {
private static final Logger log = Logger.getLogger(ContainerDiscApplication.class.getName());
private SessionCache sessionCache;
@Inject
public ContainerDiscApplication(String configId) throws ListenFailedException {
sessionCache = new SessionCache(configId);
}
AbstractModule getMbusBindings() {
return new AbstractModule() {
@Override
protected void configure() {
bind(SessionCache.class).toInstance(sessionCache);
}
};
}
public static void hackToInitializeServer(QrConfig config) {
try {
Server.get().initialize(config);
} catch (Exception e) {
log.log(LogLevel.ERROR, "Caught exception when initializing server. Exiting.", e);
Runtime.getRuntime().halt(1);
}
}
}
|