24 |
Configuration loginConfig; |
Configuration loginConfig; |
25 |
Configuration homeConfig; |
Configuration homeConfig; |
26 |
|
|
27 |
|
long cachedTime = 0; |
28 |
|
String cachedXml = ""; |
29 |
|
|
30 |
public StatusListener(Server server, Configuration loginConfig, Configuration homeConfig) { |
public StatusListener(Server server, Configuration loginConfig, Configuration homeConfig) { |
31 |
this.server = server; |
this.server = server; |
32 |
this.loginConfig = loginConfig; |
this.loginConfig = loginConfig; |
46 |
if(!event.path[0].equalsIgnoreCase("webstatus")) { |
if(!event.path[0].equalsIgnoreCase("webstatus")) { |
47 |
return; |
return; |
48 |
} |
} |
49 |
|
|
50 |
|
String xml; |
51 |
|
|
52 |
|
synchronized(this) { //is this necessary ? |
53 |
|
long now = System.currentTimeMillis(); |
54 |
|
if ( (now-cachedTime) > 5000) { |
55 |
|
xml = buildXML(); |
56 |
|
cachedXml = xml; |
57 |
|
cachedTime = now; |
58 |
|
} else { |
59 |
|
xml = cachedXml; |
60 |
|
} |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
event.setResponse(xml); |
65 |
|
event.setActionTaken(true); |
66 |
|
} |
67 |
|
|
68 |
|
private String buildXML() { |
69 |
|
|
70 |
StringBuilder sb = new StringBuilder(); |
StringBuilder sb = new StringBuilder(); |
71 |
|
|
72 |
sb.append("<?xml version=\"1.0\"?> \n"); |
sb.append("<?xml version=\"1.0\"?> \n"); |
145 |
sb.append("</plugins>\n"); |
sb.append("</plugins>\n"); |
146 |
|
|
147 |
sb.append("</serverinfo>"); |
sb.append("</serverinfo>"); |
148 |
event.setResponse(sb.toString()); |
|
149 |
event.setActionTaken(true); |
return sb.toString(); |
150 |
|
|
151 |
} |
} |
152 |
|
|