KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > protocols > HDRS


1 // $Id: HDRS.java,v 1.2 2004/03/30 06:47:21 belaban Exp $
2

3 package org.jgroups.protocols;
4
5 import org.jgroups.Event;
6 import org.jgroups.Message;
7 import org.jgroups.stack.Protocol;
8
9
10 /**
11  * Example of a protocol layer. Contains no real functionality, can be used as a template.
12  */

13 public class HDRS extends Protocol {
14     public String JavaDoc getName() {return "HDRS";}
15
16
17     private void printMessage(Message msg, String JavaDoc label) {
18     System.out.println("------------------------- " + label + " ----------------------");
19     System.out.println(msg);
20     msg.printObjectHeaders();
21     System.out.println("--------------------------------------------------------------");
22     }
23
24
25     public void up(Event evt) {
26     if(evt.getType() == Event.MSG) {
27         Message msg=(Message)evt.getArg();
28         printMessage(msg, "up");
29     }
30     passUp(evt); // Pass up to the layer above us
31
}
32
33
34
35     public void down(Event evt) {
36     if(evt.getType() == Event.MSG) {
37         Message msg=(Message)evt.getArg();
38         printMessage(msg, "down");
39     }
40
41     passDown(evt); // Pass on to the layer below us
42
}
43
44
45 }
46
Popular Tags