ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package org.jbpm.pvm.internal.util;
 
import java.util.List;
 
 
/** dispatches events to which {@link Listener listeners} can subscribe. 
 * Aka publish-subscribe.
 * 
 * @see DefaultObservable a default implementation of this interface
 * @author Tom Baeyens
 */
public interface Observable {
  
  /** subscribes a listener to every event 
   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
   */
  void addListener(Listener listener);
 
  /** removes a listener that was subscribed for every event 
   */
  void removeListener(Listener listener);
  
  /** subscribes the listener to receive event notifications only of the given eventName.  Events with 
   * different eventNames will not be dispatched to the given listener.
   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
   * @param eventName is the type of events the listener is interested in and this is mandatory.
   * @return the {@link FilterListener} that is created as a wrapper for the given listener.  That handle
   *   might be necessary to remove the listener later on.
   * @throws NullPointerException in case listener or eventName is null. */
  Listener addListener(Listener listener, String eventName);
 
  /** subscribes the listener to receive event notifications only if event matches one of the 
   * given eventNames.  Events with different eventNames will not be dispatched to the given listener.
   * @param listener is the object that will be notified on {@link #fire(String, Object) firing} of events.
   * @param eventNames is the type of events the listener is interested in and this is mandatory.
   * @return the {@link FilterListener} that is created as a wrapper for the given listener.  That handle
   *   might be necessary to remove the listener later on.
   * @throws NullPointerException in case listener or eventName is null. */
  Listener addListener(Listener listener, List<String> eventNames);
 
  /** dispatches an event to the listeners.  
   * @param eventName identifies the type of event and is allowed to be null.
   */ 
  void fire(String eventName);
 
  /** dispatches an event to the listeners.
  * @param eventName identifies the type of event and is allowed to be null.
  * @param info is the optional information that the observable wants to pass to it's listeners.  
  *   Each observable should indicate which type of info it's passing for each event.
  */  
  void fire(String eventName, Object info);
}