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