Class EPStatementImpl
- All Implemented Interfaces:
EPIterable
,EPListenable
,EPStatement
,EPStatementSPI
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected final com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView
protected com.espertech.esper.common.internal.view.core.Viewable
protected final com.espertech.esper.common.internal.context.util.StatementContext
protected final StatementResultServiceImpl
-
Constructor Summary
-
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.protected void
Returns statement annotations.Returns the deployment id.com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView
com.espertech.esper.common.client.EventType
Returns the type of events the statement pushes to listeners or returns for iterator.getName()
Returns the statement name.com.espertech.esper.common.internal.view.core.Viewable
Returns the parent view.getProperty
(com.espertech.esper.common.client.util.StatementProperty field) Returns a statement property value.com.espertech.esper.common.internal.context.util.StatementContext
Returns the statement context.int
Returns the statement id.Returns the current subscriber instance that receives statement results.Returns an iterator of update listeners.Returns the application defined user data object associated with the statement at compile time, or null if none was supplied at time of statement compilation.Returns the application defined user data object associated with the statement at deployment time, or null if none was supplied at time of deployment.boolean
Returns true if the statement has been undeployed.Iterator<com.espertech.esper.common.client.EventBean>
iterator()
Returns a concurrency-unsafe iterator over events representing statement results (pull API).Iterator<com.espertech.esper.common.client.EventBean>
iterator
(com.espertech.esper.common.client.context.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.void
recoveryUpdateListeners
(EPStatementListenerSet listenerSet) void
Remove all listeners.void
removeListener
(UpdateListener listener) Remove a listener that observes events.com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean>
Returns a concurrency-safe iterator that iterates over events representing statement results (pull API) in the face of concurrent event processing by further threads.com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean>
safeIterator
(com.espertech.esper.common.client.context.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
void
setParentView
(com.espertech.esper.common.internal.view.core.Viewable viewable) Sets the parent view.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).
-
Field Details
-
statementContext
protected final com.espertech.esper.common.internal.context.util.StatementContext statementContext -
dispatchChildView
protected final com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView dispatchChildView -
statementResultService
-
parentView
protected com.espertech.esper.common.internal.view.core.Viewable parentView -
destroyed
protected boolean destroyed
-
-
Constructor Details
-
EPStatementImpl
-
-
Method Details
-
addListener
Description copied from interface:EPListenable
Add a listener that observes events.- Specified by:
addListener
in interfaceEPListenable
- Parameters:
listener
- to add
-
getStatementId
public int getStatementId()Description copied from interface:EPStatementSPI
Returns the statement id.- Specified by:
getStatementId
in interfaceEPStatementSPI
- Returns:
- statement id
-
getStatementContext
public com.espertech.esper.common.internal.context.util.StatementContext getStatementContext()Description copied from interface:EPStatementSPI
Returns the statement context.- Specified by:
getStatementContext
in interfaceEPStatementSPI
- Returns:
- statement context
-
getName
Description copied from interface:EPStatement
Returns the statement name.- Specified by:
getName
in interfaceEPStatement
- Returns:
- statement name
-
getDispatchChildView
public com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView getDispatchChildView()- Specified by:
getDispatchChildView
in interfaceEPStatementSPI
-
isDestroyed
public boolean isDestroyed()Description copied from interface:EPStatement
Returns true if the statement has been undeployed.- Specified by:
isDestroyed
in interfaceEPStatement
- Returns:
- true for undeployed statements, false for deployed statements.
-
recoveryUpdateListeners
- Specified by:
recoveryUpdateListeners
in interfaceEPStatementSPI
-
getEventType
public com.espertech.esper.common.client.EventType getEventType()Description copied from interface:EPStatement
Returns the type of events the statement pushes to listeners or returns for iterator.For create-schema returns the created event type.
- Specified by:
getEventType
in interfaceEPStatement
- Returns:
- event type of events the iterator returns and that listeners receive
-
getAnnotations
Description copied from interface:EPStatement
Returns statement annotations.See the annotation
com.espertech.esper.common.client.annotation
package for available annotations. Application can define their own annotations.- Specified by:
getAnnotations
in interfaceEPStatement
- Returns:
- annotations or a zero-length array if no annotaions have been specified.
-
iterator
Description copied from interface:EPIterable
Returns a concurrency-unsafe iterator over events representing statement results (pull API).The iterator is useful for applications that are single-threaded, or that coordinate the iterating thread with event processing threads that use the sendEvent method using application code locks or synchronization.
The iterator returned by this method does not make any guarantees towards correctness of results and fail-behavior, if your application processes events into the runtime instance using the sendEvent method by multiple threads.
Use the safeIterator method for concurrency-safe iteration. Note the safe iterator requires applications to explicitly close the safe iterator when done iterating.
- Specified by:
iterator
in interfaceEPIterable
- Returns:
- event iterator
-
safeIterator
public com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator()Description copied from interface:EPIterable
Returns a concurrency-safe iterator that iterates over events representing statement results (pull API) in the face of concurrent event processing by further threads.In comparison to the regular iterator, the safe iterator guarantees correct results even as events are being processed by other threads. The cost is that the iterator holds one or more locks that must be released via the close method. Any locks are acquired at the time this method is called.
This method is a blocking method. It may block until statement processing locks are released such that the safe iterator can acquire any required locks.
An application MUST explicitly close the safe iterator instance using the close method, to release locks held by the iterator. The call to the close method should be done in a finally block to make sure the iterator gets closed.
Multiple safe iterators may be not be used at the same time by different application threads. A single application thread may hold and use multiple safe iterators however this is discouraged.
- Specified by:
safeIterator
in interfaceEPIterable
- Returns:
- safe iterator; NOTE: Must use the close method to close the safe iterator, preferably in a finally block
-
removeListener
Description copied from interface:EPListenable
Remove a listener that observes events.- Specified by:
removeListener
in interfaceEPListenable
- Parameters:
listener
- to remove
-
removeAllListeners
public void removeAllListeners()Description copied from interface:EPListenable
Remove all listeners.- Specified by:
removeAllListeners
in interfaceEPListenable
-
getUpdateListeners
Description copied from interface:EPListenable
Returns an iterator of update listeners.The returned iterator does not allow the remove operation.
- Specified by:
getUpdateListeners
in interfaceEPListenable
- Returns:
- iterator of update listeners
-
getParentView
public com.espertech.esper.common.internal.view.core.Viewable getParentView()Description copied from interface:EPStatementSPI
Returns the parent view.- Specified by:
getParentView
in interfaceEPStatementSPI
- Returns:
- viewable is the statement parent viewable
-
setParentView
public void setParentView(com.espertech.esper.common.internal.view.core.Viewable viewable) Description copied from interface:EPStatementSPI
Sets the parent view.- Specified by:
setParentView
in interfaceEPStatementSPI
- Parameters:
viewable
- is the statement viewable
-
setDestroyed
public void setDestroyed()- Specified by:
setDestroyed
in interfaceEPStatementSPI
-
iterator
public Iterator<com.espertech.esper.common.client.EventBean> iterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector) Description copied from interface:EPIterable
For use with statements that have a context declared and that may therefore have multiple context partitions, allows to iterate over context partitions selectively.- Specified by:
iterator
in interfaceEPIterable
- Parameters:
selector
- selects context partitions to consider- Returns:
- iterator
-
safeIterator
public com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector) Description copied from interface:EPIterable
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.- Specified by:
safeIterator
in interfaceEPIterable
- Parameters:
selector
- selects context partitions to consider- Returns:
- safe iterator
-
getDeploymentId
Description copied from interface:EPStatement
Returns the deployment id.- Specified by:
getDeploymentId
in interfaceEPStatement
- Returns:
- deployment id
-
setSubscriber
Description copied from interface:EPStatement
Attaches a subscriber to receive statement results, or removes a previously set subscriber (by providing a null value).Note: Requires the allow-subscriber compiler options.
Only a single subscriber may be set for a statement. If this method is invoked twice any previously-set subscriber is no longer used.- Specified by:
setSubscriber
in interfaceEPStatement
- Parameters:
subscriber
- to attach, or null to remove the previously set subscriber
-
setSubscriber
Description copied from interface:EPStatement
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).Note: Requires the allow-subscriber compiler options.
Only a single subscriber may be set for a statement. If this method is invoked twice any previously-set subscriber is no longer used.- Specified by:
setSubscriber
in interfaceEPStatement
- Parameters:
subscriber
- to attach, or null to remove the previously set subscribermethodName
- the name of the method to invoke, or null for the "update" method
-
getSubscriber
Description copied from interface:EPStatement
Returns the current subscriber instance that receives statement results.- Specified by:
getSubscriber
in interfaceEPStatement
- Returns:
- subscriber object, or null to indicate that no subscriber is attached
-
getProperty
Description copied from interface:EPStatement
Returns a statement property value.- Specified by:
getProperty
in interfaceEPStatement
- Parameters:
field
- statement property value- Returns:
- property or null if not set
-
addListenerWithReplay
Description copied from interface:EPListenable
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.
- Specified by:
addListenerWithReplay
in interfaceEPListenable
- Parameters:
listener
- to add
-
getUserObjectCompileTime
Description copied from interface:EPStatement
Returns the application defined user data object associated with the statement at compile time, or null if none was supplied at time of statement compilation.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 compilation via options.
- Specified by:
getUserObjectCompileTime
in interfaceEPStatement
- Returns:
- user object or null if none defined
-
getUserObjectRuntime
Description copied from interface:EPStatement
Returns the application defined user data object associated with the statement at deployment time, or null if none was supplied at time of deployment.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 deployment via options.
- Specified by:
getUserObjectRuntime
in interfaceEPStatement
- Returns:
- user object or null if none defined
-
checkDestroyed
protected void checkDestroyed()
-