Package org.apache.cayenne.event
Interface EventManager
- All Known Implementing Classes:
- DefaultEventManager,- NoopEventManager
public interface EventManager
This class acts as bridge between an Object that wants to inform others about its
 current state or a change thereof (Publisher) and a list of objects interested in the
 Subject (Listeners).
- Since:
- 3.1 before 3.1 this was a concrete class.
- 
Method SummaryModifier and Type Method Description voidaddListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject)Register anEventListenerfor events sent by any sender.voidaddListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject, Object sender)Register anEventListenerfor events sent by a specific sender.voidaddNonBlockingListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject)voidaddNonBlockingListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject, Object sender)booleanisSingleThreaded()Returns true if this EventManager is single-threaded.voidpostEvent(EventObject event, EventSubject subject)Sends an event to all registered objects about a particular subject.voidpostNonBlockingEvent(EventObject event, EventSubject subject)Sends an event to all registered objects about a particular subject.booleanremoveAllListeners(EventSubject subject)Removes all listeners for a given subject.booleanremoveListener(Object listener)Unregister the specified listener from all event subjects handled by this manager instance.booleanremoveListener(Object listener, EventSubject subject)Unregister the specified listener for the events about the given subject.booleanremoveListener(Object listener, EventSubject subject, Object sender)Unregister the specified listener for the events about the given subject and the given sender.
- 
Method Details- 
isSingleThreadedboolean isSingleThreaded()Returns true if this EventManager is single-threaded. If so it will throw an exception on any attempt to register an unblocking listener or dispatch a non-blocking event.- Since:
- 1.2
 
- 
addListenervoid addListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject)Register anEventListenerfor events sent by any sender.- Throws:
- RuntimeException- if- methodNameis not found.
 
- 
addNonBlockingListenervoid addNonBlockingListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject)
- 
addListenervoid addListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject, Object sender)Register anEventListenerfor events sent by a specific sender.- Parameters:
- listener- the object to be notified about events
- methodName- the name of the listener method to be invoked
- eventParameterClass- the class of the single event argument passed to- methodName
- subject- the event subject that the listener is interested in
- sender- the object whose events the listener is interested in;- nullmeans 'any sender'.
- Throws:
- RuntimeException- if- methodNameis not found
 
- 
addNonBlockingListenervoid addNonBlockingListener(Object listener, String methodName, Class<?> eventParameterClass, EventSubject subject, Object sender)
- 
removeListenerUnregister the specified listener from all event subjects handled by this manager instance.- Parameters:
- listener- the object to be unregistered
- Returns:
- trueif- listenercould be removed for any existing subjects, else returns- false.
 
- 
removeAllListenersRemoves all listeners for a given subject.
- 
removeListenerUnregister the specified listener for the events about the given subject.- Parameters:
- listener- the object to be unregistered
- subject- the subject from which the listener is to be unregistered
- Returns:
- trueif- listenercould be removed for the given subject, else returns- false.
 
- 
removeListenerUnregister the specified listener for the events about the given subject and the given sender.- Parameters:
- listener- the object to be unregistered
- subject- the subject from which the listener is to be unregistered
- sender- the object whose events the listener was interested in;- nullmeans 'any sender'.
- Returns:
- trueif- listenercould be removed for the given subject, else returns- false.
 
- 
postEventSends an event to all registered objects about a particular subject. Event is sent synchronously, so the sender thread is blocked until all the listeners finish processing the event.- Parameters:
- event- the event to be posted to the observers
- subject- the subject about which observers will be notified
- Throws:
- IllegalArgumentException- if event or subject are null
 
- 
postNonBlockingEventSends an event to all registered objects about a particular subject. Event is queued by EventManager, releasing the sender thread, and is later dispatched in a separate thread.- Parameters:
- event- the event to be posted to the observers
- subject- the subject about which observers will be notified
- Throws:
- IllegalArgumentException- if event or subject are null
- Since:
- 1.1
 
 
-