KickJava   Java API By Example, From Geeks To Geeks.

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


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
7
8 public class MainReplica {
9 // TODO Fix exception that is thrown when replicating with no transactionLog created.
10
public static void main(String JavaDoc[] args) throws Exception JavaDoc {
11         out( "This demo shows how your application can be replicated"
12             + "\nwithout changing ONE SINGLE LINE OF CODE in the"
13             + "\nbusiness classes or GUI. This enables query load-"
14             + "\nbalancing and system fault-tolerance.\n\n"
15         );
16
17         if (args.length != 1) {
18             out( "Usage: java MainReplica <Server IP Address>"
19                 + "\nExample: java MainReplica 10.42.10.5"
20                 + "\nExample: java MainReplica localhost"
21                 + "\n\nBefore that, though, you must run: java MainReplicaServer"
22                 + "\non this machine or any other in your network, if you haven't"
23                 + "\nalready done so.\n\n"
24             );
25             return;
26         }
27
28         PrevaylerFactory factory = new PrevaylerFactory();
29         factory.configurePrevalentSystem(new Bank());
30         factory.configurePrevalenceBase("demo2Replica");
31         factory.configureReplicationClient(args[0], PrevaylerFactory.DEFAULT_REPLICATION_PORT);
32         Prevayler prevayler = factory.create();
33
34         Main.startSnapshots(prevayler);
35     }
36
37
38     private static void out(String JavaDoc message) {
39         System.out.println(message);
40     }
41
42 }
43
Popular Tags