| <- The JWIG Runtime System | Contents | Updating a Running Service -> | 
    public class Game extends Service {
        protected int visitors = 0;
        synchronized int hit() {
            return ++visitors;
        }
        ...
    }
 | 
class dk.brics.jwig.runwig.Service
public static void checkpoint()
                       throws java.io.IOException
  | 
class dk.brics.jwig.runwig.Service
public static void rollback()
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
  | 
class dk.brics.jwig.runwig.XMLSerializable
public org.jdom.Element toXML() 
  | 
class dk.brics.jwig.runwig.XMLSerializable
public void fromXML(org.jdom.Element e) 
  | 
    public class MyService extends Service implements XMLSerializable {
        class Person {
            String login;
            String password;
            String name;
            
            Person(String login, String password, String name) {
                this.login = login;
                this.password = password;
                this.name = name;
            }
        }
    
        HashMap people = new HashMap();
    
        public Element toXML() {
            Element e = new Element("people");
            Iterator i = people.values().iterator();
            while (i.hasNext()) {
                Person p = (Person) i.next();
                Element f = new Element("person").
                    addContent(new Element("login").addContent(p.login)).
                    addContent(new Element("password").addContent(p.password)).
                    addContent(new Element("name").addContent(p.name));
                e.addContent(f);
            }
            return e;
        }
        
        public void fromXML(Element e) {
            people = new HashMap();
            Iterator i = e.getChildren().iterator();
            while (i.hasNext()) {
                Element f = (Element) i.next();
                Person p = new Person(f.getChildText("login"),
                                      f.getChildText("password"),
                                      f.getChildText("name"));
                people.put(p.login, p);
            }
        }
    
        synchronized void addPerson(String login, String password, String name) {
            people.put(login, new Person(login, password, name));
            log(Log.INFO, "added user: "+login);
            try { 
                checkpoint();
            } catch (IOException e) {
                log(Log.ERR, "unable to checkpoint");
            }
        }
        ...
    }
 | 
| <- The JWIG Runtime System | Contents | Updating a Running Service -> |