public interface EPStatement extends EPListenable, EPIterable
Statements have 3 states: STARTED, STOPPED and DESTROYED.
In started state, statements are actively evaluating event streams according to the statement expression. Started statements can be stopped and destroyed.
In stopped state, statements are inactive. Stopped statements can either be started, in which case they begin to actively evaluate event streams, or destroyed.
Destroyed statements have relinguished all statement resources and cannot be started or stopped.
Modifier and Type | Method and Description |
---|---|
void |
addListenerWithReplay(UpdateListener listener)
Add an update listener replaying current statement results to the listener.
|
void |
destroy()
Destroy the statement releasing all statement resources.
|
Annotation[] |
getAnnotations()
Returns EPL or pattern statement annotations provided in the statement text, if any.
|
String |
getName()
Returns the statement name.
|
String |
getServiceIsolated()
Returns the name of the isolated service provided is the statement is currently
isolated in terms of event visibility and scheduling,
or returns null if the statement is live in the engine.
|
EPStatementState |
getState()
Returns the statement's current state.
|
Object |
getSubscriber()
Returns the current subscriber instance that receives statement results.
|
String |
getText()
Returns the underlying expression text.
|
long |
getTimeLastStateChange()
Returns the system time in milliseconds of when the statement last change state.
|
Object |
getUserObject()
Returns the application defined user data object associated with the statement, or null if none
was supplied at time of statement creation.
|
boolean |
isDestroyed()
Returns true if the statement state is destroyed.
|
boolean |
isPattern()
Returns true if statement is a pattern
|
boolean |
isStarted()
Returns true if the statement state is started.
|
boolean |
isStopped()
Returns true if the statement state is stopped.
|
Iterator<EventBean> |
iterator(ContextPartitionSelector selector)
For use with statements that have a context declared and that may therefore have multiple context partitions,
allows to iterate over context partitions selectively.
|
SafeIterator<EventBean> |
safeIterator(ContextPartitionSelector selector)
For use with statements that have a context declared and that may therefore have multiple context partitions,
allows to safe-iterate over context partitions selectively.
|
void |
setSubscriber(Object subscriber)
Attaches a subscriber to receive statement results,
or removes a previously set subscriber (by providing a null value).
|
void |
setSubscriber(Object subscriber,
String methodName)
Attaches a subscriber to receive statement results by calling the method with the provided method name,
or removes a previously set subscriber (by providing a null value).
|
void |
start()
Start the statement.
|
void |
stop()
Stop the statement.
|
addListener, addListener, getStatementAwareListeners, getUpdateListeners, removeAllListeners, removeListener, removeListener
getEventType, iterator, safeIterator
void start()
void stop()
void destroy()
A destroyed statement cannot be started again.
EPStatementState getState()
boolean isStarted()
boolean isStopped()
boolean isDestroyed()
String getText()
String getName()
long getTimeLastStateChange()
void setSubscriber(Object subscriber) throws EPSubscriberException
Only a single subscriber may be set for a statement. If this method is invoked twice any previously-set subscriber is no longer used.
subscriber
- to attach, or null to remove the previously set subscriberEPSubscriberException
- if the subscriber does not provide the methods
needed to receive statement resultsvoid setSubscriber(Object subscriber, String methodName) throws EPSubscriberException
Only a single subscriber may be set for a statement. If this method is invoked twice any previously-set subscriber is no longer used.
subscriber
- to attach, or null to remove the previously set subscribermethodName
- the name of the method to invoke, or null for the "update" methodEPSubscriberException
- if the subscriber does not provide the methods
needed to receive statement resultsObject getSubscriber()
EPSubscriberException
- if the subscriber does not provide the methods
needed to receive statement resultsboolean isPattern()
Object getUserObject()
The user object is a single, unnamed field that is stored with every statement. Applications may put arbitrary objects in this field or a null value.
User objects are passed at time of statement creation as a parameter the create method.
void addListenerWithReplay(UpdateListener 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.
listener
- to addAnnotation[] getAnnotations()
See the annotation com.espertech.esper.client.annotation
package for
available annotations.
String getServiceIsolated()
Iterator<EventBean> iterator(ContextPartitionSelector selector)
selector
- selects context partitions to considerSafeIterator<EventBean> safeIterator(ContextPartitionSelector selector)
selector
- selects context partitions to consider