Interface EPListenable
- All Known Subinterfaces:
EPStatement
,EPStatementSPI
- All Known Implementing Classes:
EPStatementImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(UpdateListener listener) Add a listener that observes events.void
addListenerWithReplay
(UpdateListener listener) Add an update listener replaying current statement results to the listener.Returns an iterator of update listeners.void
Remove all listeners.void
removeListener
(UpdateListener listener) Remove a listener that observes events.
-
Method Details
-
addListener
Add a listener that observes events.- Parameters:
listener
- to add- Throws:
IllegalStateException
- when attempting to add a listener to a destroyed statement
-
removeListener
Remove a listener that observes events.- Parameters:
listener
- to remove
-
removeAllListeners
void removeAllListeners()Remove all listeners. -
getUpdateListeners
Iterator<UpdateListener> getUpdateListeners()Returns an iterator of update listeners.The returned iterator does not allow the remove operation.
- Returns:
- iterator of update listeners
-
addListenerWithReplay
Add an update listener replaying current statement results to the listener.The listener receives current statement results as the first call to the update method of the listener, passing in the newEvents parameter the current statement results as an array of zero or more events. Subsequent calls to the update method of the listener are statement results.
Current statement results are the events returned by the iterator or safeIterator methods.
Delivery of current statement results in the first call is performed by the same thread invoking this method, while subsequent calls to the listener may deliver statement results by the same or other threads.
Note: this is a blocking call, delivery is atomic: Events occurring during iteration and delivery to the listener are guaranteed to be delivered in a separate call and not lost. The listener implementation should minimize long-running or blocking operations.
Delivery is only atomic relative to the current statement. If the same listener instance is registered with other statements it may receive other statement result s simultaneously.
If a statement is not started an therefore does not have current results, the listener receives a single invocation with a null value in newEvents.
- Parameters:
listener
- to add
-