01: // $Id: HDRS.java,v 1.2 2004/03/30 06:47:21 belaban Exp $
02:
03: package org.jgroups.protocols;
04:
05: import org.jgroups.Event;
06: import org.jgroups.Message;
07: import org.jgroups.stack.Protocol;
08:
09: /**
10: * Example of a protocol layer. Contains no real functionality, can be used as a template.
11: */
12: public class HDRS extends Protocol {
13: public String getName() {
14: return "HDRS";
15: }
16:
17: private void printMessage(Message msg, String label) {
18: System.out.println("------------------------- " + label
19: + " ----------------------");
20: System.out.println(msg);
21: msg.printObjectHeaders();
22: System.out
23: .println("--------------------------------------------------------------");
24: }
25:
26: public void up(Event evt) {
27: if (evt.getType() == Event.MSG) {
28: Message msg = (Message) evt.getArg();
29: printMessage(msg, "up");
30: }
31: passUp(evt); // Pass up to the layer above us
32: }
33:
34: public void down(Event evt) {
35: if (evt.getType() == Event.MSG) {
36: Message msg = (Message) evt.getArg();
37: printMessage(msg, "down");
38: }
39:
40: passDown(evt); // Pass on to the layer below us
41: }
42:
43: }
|