1package autotest.common;
2
3import com.google.gwt.json.client.JSONValue;
4import com.google.gwt.user.client.Timer;
5import com.google.gwt.user.client.ui.RootPanel;
6
7public class CommonClassFactory {
8
9    public static void globalInitialize() {
10        setupMOTD();
11
12        Timer timer = new Timer() {
13            @Override
14            public void run() {
15                refreshMOTD();
16            }
17        };
18
19        // schedule every 10 minutes
20        timer.scheduleRepeating(10 * 60 * 1000);
21    }
22
23    public static void setupMOTD() {
24        String motd = StaticDataRepository.getRepository().getData(
25                "motd").isString().stringValue();
26        RootPanel.get("motd").getElement().setInnerHTML(motd);
27    }
28
29    public static void refreshMOTD() {
30        JsonRpcProxy.getProxy().rpcCall("get_motd", null, new JsonRpcCallback() {
31            @Override
32            public void onSuccess(JSONValue result) {
33                String motd = result.isString().stringValue();
34                RootPanel.get("motd").getElement().setInnerHTML(motd);
35            }
36        });
37    }
38}
39