KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > stack > ProtocolObserver


1 // $Id: ProtocolObserver.java,v 1.1.1.1 2003/09/09 01:24:12 belaban Exp $
2

3 package org.jgroups.stack;
4
5
6 import org.jgroups.Event;
7
8
9 /**
10  * Interface for the Debugger to receive notifications about a protocol layer. Defines the
11  * hooks called by Protocol when significant events occur, e.g. an event has been received.
12  * Every ProtocolObserver should have a reference to the protocol it monitors.
13  * @author Bela Ban, July 22 2000
14  */

15 public interface ProtocolObserver {
16
17     /**
18        Called when a ProtocolObserver is attached to a protcol. This reference can be used to
19        modify the up-/down-queues, reorder events, inject new events etc.
20      */

21     void setProtocol(Protocol prot);
22     
23
24     
25     /** Called when an event is about to be dispatched to the protocol (before it is dispatched).
26     The up handler thread will block until this method returns. This allows an implementor
27     to block indefinitely, and only process single events at a time, e.g. for single-stepping.
28     For example, upon clicking on a button "Step" in the Debugger GUI, the method would unblock
29     (waiting on a mutex, GUI thread notifies mutex).
30     @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
31     to the event will be seen by the protocol !</em>
32     @param num_evts The number of events currently in the up-queue (including this event).
33     This number may increase while we're in the callback as the up-handler thread in the
34     upper protocol layer puts new events into the up queue.
35     @return boolean If true the event is processed, else it will be discarded (not be given
36     to the protocol layer to process).
37     */

38     boolean up(Event evt, int num_evts);
39
40
41     
42     /** Called when an event is about to be passed up to the next higher protocol.
43     @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
44     to the event will be seen by the protocol !</em>
45     @return boolean If true the event is passed up, else it will be discarded (not be given
46     to the protocol layer above to process).
47     */

48     boolean passUp(Event evt);
49
50
51
52     
53     /** Called when an event is about to be dispatched to the protocol (before it is dispatched).
54     The down handler thread will block until this method returns. This allows an implementor
55     to block indefinitely, and only process single events at a time, e.g. for single-stepping.
56     For example, upon clicking on a button "Step" in the Debugger GUI, the method would unblock
57     (waiting on a mutex, GUI thread notifies mutex).
58     @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
59     to the event will be seen by the protocol !</em>
60     @param num_evts The number of events currently in the down-queue (including this event).
61     This number may increase while we're in the callback as the down-handler thread in the
62     upper protocol layer puts new events into the down queue.
63     @return boolean If true the event is processed, else it will be discarded (not be given
64     to the protocol layer to process).
65     */

66     boolean down(Event evt, int num_evts);
67
68
69     
70     /** Called when an event is about to be passed down to the next lower protocol.
71     @param evt The event to be processed by the protocol. <em>This is not a copy, so changes
72     to the event will be seen by the protocol !</em>
73     @return boolean If true the event is passed down, else it will be discarded (not be given
74     to the protocol layer below to process).
75     */

76     boolean passDown(Event evt);
77 }
78
Popular Tags