View Javadoc

1   /*
2    * @(#)EventProducerInterface April 4, 2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.event;
11  
12  import java.rmi.RemoteException;
13  
14  /***
15   * The EventProducerInterface defines the registration operations of an
16   * eventproducer. This behavior includes adding and removing listeners for a
17   * specific event type.
18   * <p>
19   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
20   * University of Technology </a>, the Netherlands. <br>
21   * See for project information <a
22   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
23   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24   * License (GPL) </a>, no warranty <br>
25   * 
26   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
27   *         Jacobs </a>
28   * @version 1.11 2004-03-18
29   * @since 1.0
30   */
31  public interface EventProducerInterface
32  {
33  	/*** The FIRST_POSITION in the queue */
34  	short FIRST_POSITION = 0;
35  
36  	/*** The LAST_POSITION in the queue */
37  	short LAST_POSITION = -1;
38  
39  	/***
40  	 * adds a listener as strong reference to the BEGINNING of a queue of
41  	 * listeners.
42  	 * 
43  	 * @param listener the listener which is interested at events of eventtype.
44  	 * @param eventType the events of interest.
45  	 * @return the success of adding the listener. If a listener was already
46  	 *         added false is returned.
47  	 * @throws RemoteException If a network connection failure occurs.
48  	 * @see nl.tudelft.simulation.event.ref.WeakReference
49  	 */
50  	boolean addListener(EventListenerInterface listener, EventType eventType)
51  			throws RemoteException;
52  
53  	/***
54  	 * adds a listener to the BEGINNING of a queue of listeners.
55  	 * 
56  	 * @param listener the listener which is interested at events of eventtype.
57  	 * @param eventType the events of interest.
58  	 * @param weak whether or not the listener is added as weak reference.
59  	 * @return the success of adding the listener. If a listener was already
60  	 *         added false is returned.
61  	 * @throws RemoteException If a network connection failure occurs.
62  	 * @see nl.tudelft.simulation.event.ref.WeakReference
63  	 */
64  	boolean addListener(EventListenerInterface listener, EventType eventType,
65  			boolean weak) throws RemoteException;
66  
67  	/***
68  	 * adds a listener as strong reference to the specified position of a queue
69  	 * of listeners.
70  	 * 
71  	 * @param listener the listener which is interested at events of eventtype.
72  	 * @param eventType the events of interest.
73  	 * @param position the position of the listener in the queue.
74  	 * @return the success of adding the listener. If a listener was already
75  	 *         added, or an illegal position is provided false is returned.
76  	 * @throws RemoteException If a network connection failure occurs.
77  	 * @see nl.tudelft.simulation.event.ref.WeakReference
78  	 */
79  	boolean addListener(EventListenerInterface listener, EventType eventType,
80  			short position) throws RemoteException;
81  
82  	/***
83  	 * adds a listener to the specified position of a queue of listeners.
84  	 * 
85  	 * @param listener which is interested at certain events,
86  	 * @param eventType the events of interest.
87  	 * @param position the position of the listener in the queue
88  	 * @param weak whether the reference should be weak or strong.
89  	 * @return the success of adding the listener. If a listener was already
90  	 *         added or an illegal position is provided false is returned.
91  	 * @throws RemoteException If a network connection failure occurs.
92  	 */
93  	boolean addListener(EventListenerInterface listener, EventType eventType,
94  			short position, boolean weak) throws RemoteException;
95  
96  	/***
97  	 * returns all the eventTypes for which a listener can subscribe.
98  	 * 
99  	 * @return EventType[] returns the eventTypes for which listeners can
100 	 *         subscribe.
101 	 * @throws RemoteException If a network connection failure occurs.
102 	 */
103 	EventType[] getEventTypes() throws RemoteException;
104 
105 	/***
106 	 * removes the subscription of a listener for a specific event.
107 	 * 
108 	 * @param listener which is no longer interested.
109 	 * @param eventType the event which is of no interest any more.
110 	 * @return the success of removing the listener. If a listener was not
111 	 *         subscribed false is returned.
112 	 * @throws RemoteException If a network connection failure occurs.
113 	 */
114 	boolean removeListener(EventListenerInterface listener, EventType eventType)
115 			throws RemoteException;
116 }