KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.prevayler.demos.demo2;
2
3 import org.prevayler.Prevayler;
4 import org.prevayler.PrevaylerFactory;
5 import org.prevayler.demos.demo2.business.Bank;
6 import org.prevayler.demos.demo2.gui.BankFrame;
7
8
9 public class Main {
10     
11     public static void main(String JavaDoc[] ignored) throws Exception JavaDoc {
12         out("\nOne snapshot per day is more than enough for most applications"
13             + "\n because the transactionLog recovery rate is in the order of"
14             + "\n 6000 transactions per second. For demoing purposes, though, a"
15             + "\n snapshot will be taken every 20 seconds...");
16
17         Prevayler prevayler = PrevaylerFactory.createPrevayler(new Bank(), "demo2");
18         startSnapshots(prevayler);
19     }
20
21     static void startSnapshots(Prevayler prevayler) throws Exception JavaDoc {
22         startGui(prevayler);
23
24         while (true) {
25             Thread.sleep(1000 * 20);
26             prevayler.takeSnapshot();
27             out("Snapshot taken at " + new java.util.Date JavaDoc() + "...");
28         }
29     }
30
31     static void startGui(Prevayler prevayler) {
32         new BankFrame(prevayler);
33     }
34     
35     private static void out(String JavaDoc message) {
36         System.out.println(message);
37     }
38
39 }
40
Popular Tags