// test notification
// simple registration
{
logln("simple registration notification");
ICULocaleService ls = new ICULocaleService();
ServiceListener l1 = new ServiceListener() {
private int n;
public void serviceChanged(ICUService s) {
logln("listener 1 report " + n++ + " service changed: " + s);
}
};
ls.addListener(l1);
ServiceListener l2 = new ServiceListener() {
private int n;
public void serviceChanged(ICUService s) {
logln("listener 2 report " + n++ + " service changed: " + s);
}
};
ls.addListener(l2);
logln("registering foo... ");
ls.registerObject("Foo", "en_FOO");
logln("registering bar... ");
ls.registerObject("Bar", "en_BAR");
logln("getting foo...");
logln((String)ls.get("en_FOO"));
logln("removing listener 2...");
ls.removeListener(l2);
logln("registering baz...");
ls.registerObject("Baz", "en_BAZ");
logln("removing listener 1");
ls.removeListener(l1);
logln("registering burp...");
ls.registerObject("Burp", "en_BURP");
// should only get one notification even if register multiple times
logln("... trying multiple registration");
ls.addListener(l1);
ls.addListener(l1);
ls.addListener(l1);
ls.addListener(l2);
ls.registerObject("Foo", "en_FOO");
logln("... registered foo");
// since in a separate thread, we can callback and not deadlock
ServiceListener l3 = new ServiceListener() {
private int n;
public void serviceChanged(ICUService s) {
logln("listener 3 report " + n++ + " service changed...");
if (s.get("en_BOINK") == null) { // don't recurse on ourselves!!!
logln("registering boink...");