01: // $Id: ProtocolObserver.java,v 1.1.1.1 2003/09/09 01:24:12 belaban Exp $
02:
03: package org.jgroups.stack;
04:
05: import org.jgroups.Event;
06:
07: /**
08: * Interface for the Debugger to receive notifications about a protocol layer. Defines the
09: * hooks called by Protocol when significant events occur, e.g. an event has been received.
10: * Every ProtocolObserver should have a reference to the protocol it monitors.
11: * @author Bela Ban, July 22 2000
12: */
13: public interface ProtocolObserver {
14:
15: /**
16: Called when a ProtocolObserver is attached to a protcol. This reference can be used to
17: modify the up-/down-queues, reorder events, inject new events etc.
18: */
19: void setProtocol(Protocol prot);
20:
21: /** Called when an event is about to be dispatched to the protocol (before it is dispatched).
22: The up handler thread will block until this method returns. This allows an implementor
23: to block indefinitely, and only process single events at a time, e.g. for single-stepping.
24: For example, upon clicking on a button "Step" in the Debugger GUI, the method would unblock
25: (waiting on a mutex, GUI thread notifies mutex).
26: @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
27: to the event will be seen by the protocol !</em>
28: @param num_evts The number of events currently in the up-queue (including this event).
29: This number may increase while we're in the callback as the up-handler thread in the
30: upper protocol layer puts new events into the up queue.
31: @return boolean If true the event is processed, else it will be discarded (not be given
32: to the protocol layer to process).
33: */
34: boolean up(Event evt, int num_evts);
35:
36: /** Called when an event is about to be passed up to the next higher protocol.
37: @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
38: to the event will be seen by the protocol !</em>
39: @return boolean If true the event is passed up, else it will be discarded (not be given
40: to the protocol layer above to process).
41: */
42: boolean passUp(Event evt);
43:
44: /** Called when an event is about to be dispatched to the protocol (before it is dispatched).
45: The down handler thread will block until this method returns. This allows an implementor
46: to block indefinitely, and only process single events at a time, e.g. for single-stepping.
47: For example, upon clicking on a button "Step" in the Debugger GUI, the method would unblock
48: (waiting on a mutex, GUI thread notifies mutex).
49: @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
50: to the event will be seen by the protocol !</em>
51: @param num_evts The number of events currently in the down-queue (including this event).
52: This number may increase while we're in the callback as the down-handler thread in the
53: upper protocol layer puts new events into the down queue.
54: @return boolean If true the event is processed, else it will be discarded (not be given
55: to the protocol layer to process).
56: */
57: boolean down(Event evt, int num_evts);
58:
59: /** Called when an event is about to be passed down to the next lower protocol.
60: @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
61: to the event will be seen by the protocol !</em>
62: @return boolean If true the event is passed down, else it will be discarded (not be given
63: to the protocol layer below to process).
64: */
65: boolean passDown(Event evt);
66: }
|