public class EPStatementImpl extends Object implements EPStatementSPI
Modifier and Type | Field and Description |
---|---|
protected boolean |
destroyed |
protected com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView |
dispatchChildView |
protected com.espertech.esper.common.internal.view.core.Viewable |
parentView |
protected com.espertech.esper.common.internal.context.util.StatementContext |
statementContext |
protected StatementResultServiceImpl |
statementResultService |
Constructor and Description |
---|
EPStatementImpl(EPStatementFactoryArgs args) |
Modifier and Type | Method and Description |
---|---|
void |
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 |
checkDestroyed() |
Annotation[] |
getAnnotations()
Returns statement annotations.
|
String |
getDeploymentId()
Returns the deployment id.
|
com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView |
getDispatchChildView() |
com.espertech.esper.common.client.EventType |
getEventType()
Returns the type of events the statement pushes to listeners or returns for iterator.
|
String |
getName()
Returns the statement name.
|
com.espertech.esper.common.internal.view.core.Viewable |
getParentView()
Returns the parent view.
|
Object |
getProperty(com.espertech.esper.common.client.util.StatementProperty field)
Returns a statement property value.
|
com.espertech.esper.common.internal.context.util.StatementContext |
getStatementContext()
Returns the statement context.
|
int |
getStatementId()
Returns the statement id.
|
Object |
getSubscriber()
Returns the current subscriber instance that receives statement results.
|
Iterator<UpdateListener> |
getUpdateListeners()
Returns an iterator of update listeners.
|
Object |
getUserObjectCompileTime()
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.
|
Object |
getUserObjectRuntime()
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 |
isDestroyed()
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 |
removeAllListeners()
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> |
safeIterator()
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 |
setDestroyed() |
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).
|
protected final com.espertech.esper.common.internal.context.util.StatementContext statementContext
protected final com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView dispatchChildView
protected final StatementResultServiceImpl statementResultService
protected com.espertech.esper.common.internal.view.core.Viewable parentView
protected boolean destroyed
public EPStatementImpl(EPStatementFactoryArgs args)
public void addListener(UpdateListener listener)
EPListenable
addListener
in interface EPListenable
listener
- to addpublic int getStatementId()
EPStatementSPI
getStatementId
in interface EPStatementSPI
public com.espertech.esper.common.internal.context.util.StatementContext getStatementContext()
EPStatementSPI
getStatementContext
in interface EPStatementSPI
public String getName()
EPStatement
getName
in interface EPStatement
public com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView getDispatchChildView()
getDispatchChildView
in interface EPStatementSPI
public boolean isDestroyed()
EPStatement
isDestroyed
in interface EPStatement
public void recoveryUpdateListeners(EPStatementListenerSet listenerSet)
recoveryUpdateListeners
in interface EPStatementSPI
public com.espertech.esper.common.client.EventType getEventType()
EPStatement
getEventType
in interface EPStatement
public Annotation[] getAnnotations()
EPStatement
See the annotation com.espertech.esper.common.client.annotation
package for
available annotations. Application can define their own annotations.
getAnnotations
in interface EPStatement
public Iterator<com.espertech.esper.common.client.EventBean> iterator()
EPIterable
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.
iterator
in interface EPIterable
public com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator()
EPIterable
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.
safeIterator
in interface EPIterable
public void removeListener(UpdateListener listener)
EPListenable
removeListener
in interface EPListenable
listener
- to removepublic void removeAllListeners()
EPListenable
removeAllListeners
in interface EPListenable
public Iterator<UpdateListener> getUpdateListeners()
EPListenable
The returned iterator does not allow the remove operation.
getUpdateListeners
in interface EPListenable
public com.espertech.esper.common.internal.view.core.Viewable getParentView()
EPStatementSPI
getParentView
in interface EPStatementSPI
public void setParentView(com.espertech.esper.common.internal.view.core.Viewable viewable)
EPStatementSPI
setParentView
in interface EPStatementSPI
viewable
- is the statement viewablepublic void setDestroyed()
setDestroyed
in interface EPStatementSPI
public Iterator<com.espertech.esper.common.client.EventBean> iterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
EPIterable
iterator
in interface EPIterable
selector
- selects context partitions to considerpublic com.espertech.esper.common.client.util.SafeIterator<com.espertech.esper.common.client.EventBean> safeIterator(com.espertech.esper.common.client.context.ContextPartitionSelector selector)
EPIterable
safeIterator
in interface EPIterable
selector
- selects context partitions to considerpublic String getDeploymentId()
EPStatement
getDeploymentId
in interface EPStatement
public void setSubscriber(Object subscriber)
EPStatement
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.setSubscriber
in interface EPStatement
subscriber
- to attach, or null to remove the previously set subscriberpublic void setSubscriber(Object subscriber, String methodName)
EPStatement
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.setSubscriber
in interface EPStatement
subscriber
- to attach, or null to remove the previously set subscribermethodName
- the name of the method to invoke, or null for the "update" methodpublic Object getSubscriber()
EPStatement
getSubscriber
in interface EPStatement
public Object getProperty(com.espertech.esper.common.client.util.StatementProperty field)
EPStatement
getProperty
in interface EPStatement
field
- statement property valuepublic void addListenerWithReplay(UpdateListener listener)
EPListenable
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.
addListenerWithReplay
in interface EPListenable
listener
- to addpublic Object getUserObjectCompileTime()
EPStatement
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.
getUserObjectCompileTime
in interface EPStatement
public Object getUserObjectRuntime()
EPStatement
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.
getUserObjectRuntime
in interface EPStatement
protected void checkDestroyed()
Copyright © 2005–2018. All rights reserved.