1 |
package dk.thoerup.traininfoservice; |
2 |
|
3 |
import javax.servlet.ServletContext; |
4 |
|
5 |
import dk.thoerup.circuitbreaker.config.BreakerConfig; |
6 |
import dk.thoerup.webconfig.ConfigVariable; |
7 |
import dk.thoerup.webconfig.ContextConfigLoader; |
8 |
import dk.thoerup.webconfig.ReloadConfig; |
9 |
|
10 |
|
11 |
public class TraininfoSettings implements BreakerConfig{ |
12 |
|
13 |
ServletContext cxt; |
14 |
public TraininfoSettings(ServletContext cxt) { |
15 |
this.cxt = cxt; |
16 |
} |
17 |
|
18 |
@ConfigVariable |
19 |
boolean useazuresite; |
20 |
|
21 |
@ConfigVariable(description = "Circuitbreaker", readonly = true) |
22 |
int banedk_threshold; |
23 |
|
24 |
@ConfigVariable(readonly = true) |
25 |
int banedk_timeout; |
26 |
|
27 |
@ConfigVariable(readonly = true) |
28 |
int cache_timeout; |
29 |
|
30 |
@ConfigVariable(readonly = true) |
31 |
int stats_interval; |
32 |
|
33 |
@ConfigVariable |
34 |
int reply_timeout; |
35 |
|
36 |
@ReloadConfig |
37 |
public void reloadConfig() { |
38 |
System.out.println("Reloading config"); |
39 |
new ContextConfigLoader(cxt).loadConfig(this); |
40 |
} |
41 |
|
42 |
public boolean getUseAzureSite() { |
43 |
return useazuresite; |
44 |
} |
45 |
|
46 |
|
47 |
public int getCacheTimeout() { |
48 |
return cache_timeout; |
49 |
} |
50 |
|
51 |
public int getStatsInterval() { |
52 |
return stats_interval; |
53 |
} |
54 |
|
55 |
public int getReplyTimeout() { |
56 |
return reply_timeout; |
57 |
} |
58 |
|
59 |
|
60 |
@Override |
61 |
public int getTreshold() { |
62 |
return banedk_threshold; |
63 |
} |
64 |
|
65 |
@Override |
66 |
public int getTimeout() { |
67 |
return banedk_timeout; |
68 |
} |
69 |
} |