KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > demos > DrawMultiplexer


1 package org.jgroups.demos;
2
3 import org.jgroups.Channel;
4 import org.jgroups.JChannelFactory;
5
6 /**
7  * @author Bela Ban
8  * @version $Id: DrawMultiplexer.java,v 1.7 2007/03/02 14:18:56 belaban Exp $
9  */

10 public class DrawMultiplexer {
11     JChannelFactory factory;
12
13     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
14         String JavaDoc props="stacks.xml";
15         String JavaDoc stack_name="udp";
16         boolean state=false;
17         for(int i=0; i < args.length; i++) {
18             String JavaDoc arg=args[i];
19             if(arg.equals("-props")) {
20                 props=args[++i];
21                 continue;
22             }
23             if(arg.equals("-stack_name")) {
24                 stack_name=args[++i];
25                 continue;
26             }
27             if(arg.equals("-state")) {
28                 state=true;
29                 continue;
30             }
31             System.out.println("DrawMultiplexer [-help] [-props <stack config file>] [-stack_name <name>] [-state]");
32             return;
33         }
34         new DrawMultiplexer().start(props, stack_name, state);
35     }
36
37
38     private void start(String JavaDoc props, String JavaDoc stack_name, boolean state) throws Exception JavaDoc {
39         factory=new JChannelFactory();
40         factory.setMultiplexerConfig(props);
41
42         final Channel ch1, ch2;
43         ch1=factory.createMultiplexerChannel(stack_name, "id-1");
44         Draw draw1=new Draw(ch1, state, 5000);
45         ch1.connect("bela");
46
47         ch2=factory.createMultiplexerChannel(stack_name, "id-2");
48         Draw draw2=new Draw(ch2, state, 5000);
49         ch2.connect("ban");
50
51         draw1.go();
52         draw2.go();
53     }
54 }
55
Popular Tags