1 package fr.ifremer.coser.web;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import com.google.common.base.Preconditions;
25 import fr.ifremer.coser.DefaultCoserApplicationContext;
26 import org.nuiton.i18n.I18n;
27 import org.nuiton.i18n.init.DefaultI18nInitializer;
28
29
30
31
32
33
34
35 public class CoserWebApplicationContext extends DefaultCoserApplicationContext {
36
37
38
39
40 protected static CoserWebApplicationContext context;
41
42 public static CoserWebApplicationContext get() {
43 Preconditions.checkState(context != null, "Application was not initialized!");
44 return context;
45 }
46
47 public static void init() {
48
49 DefaultI18nInitializer i18nInitializer = new DefaultI18nInitializer("coser-i18n");
50
51 i18nInitializer.setMissingKeyReturnNull(true);
52 I18n.init(i18nInitializer, null);
53
54 context = new CoserWebApplicationContext();
55 }
56
57 public static void close() {
58 context = null;
59 }
60
61 public CoserWebApplicationContext() {
62 super(new CoserWebConfig());
63 }
64
65 @Override
66 public CoserWebConfig getConfig() {
67 return (CoserWebConfig) config;
68 }
69 }