1 package org.jgroups.demos; 2 3 import org.jgroups.Channel; 4 import org.jgroups.JChannelFactory; 5 6 10 public class DrawMultiplexer { 11 JChannelFactory factory; 12 13 public static void main(String [] args) throws Exception { 14 String props="stacks.xml"; 15 String stack_name="udp"; 16 boolean state=false; 17 for(int i=0; i < args.length; i++) { 18 String 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 props, String stack_name, boolean state) throws Exception { 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 |