01: // $Id: DUMMY_TP.java,v 1.1 2005/04/14 14:39:32 belaban Exp $
02:
03: package org.jgroups.protocols;
04:
05: import org.jgroups.Address;
06: import org.jgroups.Event;
07: import org.jgroups.stack.Protocol;
08:
09: /**
10: * Dummy transport, returns a fake local address and responds to CONNECT with CONNECT_OK.
11: * Compared to LOOPBACK, this discards everything
12: * @author Bela Ban
13: * @version $Id: DUMMY_TP.java,v 1.1 2005/04/14 14:39:32 belaban Exp $
14: */
15: public class DUMMY_TP extends Protocol {
16: private Address local_addr = null;
17:
18: public DUMMY_TP() {
19: }
20:
21: public String toString() {
22: return "Protocol DUMMY_TP (local address: " + local_addr + ')';
23: }
24:
25: /*------------------------------ Protocol interface ------------------------------ */
26:
27: public String getName() {
28: return "DUMMY_TP";
29: }
30:
31: public void init() throws Exception {
32: local_addr = new org.jgroups.stack.IpAddress("localhost", 10000); // fake address
33: }
34:
35: public void start() throws Exception {
36: passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
37: }
38:
39: /**
40: * Caller by the layer above this layer. Usually we just put this Message
41: * into the send queue and let one or more worker threads handle it. A worker thread
42: * then removes the Message from the send queue, performs a conversion and adds the
43: * modified Message to the send queue of the layer below it, by calling Down).
44: */
45: public void down(Event evt) {
46:
47: switch (evt.getType()) {
48:
49: case Event.CONNECT:
50: passUp(new Event(Event.CONNECT_OK));
51: break;
52:
53: case Event.DISCONNECT:
54: passUp(new Event(Event.DISCONNECT_OK));
55: break;
56: }
57: }
58:
59: /*--------------------------- End of Protocol interface -------------------------- */
60:
61: }
|