KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > tests > UpHandlerTest


1 // $Id: UpHandlerTest.java,v 1.4 2004/07/05 14:15:11 belaban Exp $
2

3
4 package org.jgroups.tests;
5
6
7 import org.jgroups.*;
8 import org.jgroups.util.Util;
9
10
11
12 /**
13  * Uses the pass-though facility of the Channel: events are passed (mostly) unfiltered from the channel
14  * to the application. The app quickly joins a groups, sends a message and then leaves again. The events
15  * received during this period are shown.
16  * @author Bela Ban
17  */

18 public class UpHandlerTest implements UpHandler {
19     Channel channel;
20
21     public void start() throws Exception JavaDoc {
22     channel=new JChannel();
23     channel.setUpHandler(this);
24     channel.connect("UpHandlerTestGroup");
25
26     channel.send(new Message(null, null, "Hello".getBytes()));
27     Util.sleep(2000);
28     channel.close();
29     }
30
31
32     public void up(Event evt) {
33     System.out.println(evt);
34     }
35
36
37     public static void main(String JavaDoc[] args) {
38     try {
39         new UpHandlerTest().start();
40     }
41     catch(Exception JavaDoc e) {
42         System.err.println(e);
43     }
44     }
45 }
46
Popular Tags