KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > demos > demo2 > MainXStream


1 package org.prevayler.demos.demo2;
2
3 import org.prevayler.Prevayler;
4 import org.prevayler.PrevaylerFactory;
5 import org.prevayler.demos.demo2.business.Account;
6 import org.prevayler.demos.demo2.business.AccountEntry;
7 import org.prevayler.demos.demo2.business.Bank;
8 import org.prevayler.implementation.snapshot.XStreamSnapshotManager;
9
10 import com.thoughtworks.xstream.XStream;
11
12 public class MainXStream {
13
14     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
15         out("A snapshot using XStream's XML serialization will be taken every 20 seconds...");
16
17         PrevaylerFactory factory = new PrevaylerFactory();
18         factory.configurePrevalenceBase("demo2XStream");
19
20         factory.configureSnapshotManager(new XStreamSnapshotManager(new Bank(), "demo2XStream") {
21                 protected XStream createXStream() {
22                     XStream xstream = new XStream();
23                     xstream.alias("bank", Bank.class); //This mapping is optional. It just makes the XML in the snapshot file look prettier.
24
xstream.alias("account", Account.class);
25                     xstream.alias("accountEntry", AccountEntry.class);
26                     return xstream;
27                 }
28         });
29         Prevayler prevayler = factory.create();
30
31         Main.startSnapshots(prevayler);
32
33     }
34
35     private static void out(String JavaDoc message) {
36         System.out.println(message);
37     }
38 }
Popular Tags