java.lang.Object
com.espertech.esper.runtime.internal.kernel.statement.EPStatementImpl
All Implemented Interfaces:
EPIterable, EPListenable, EPStatement, EPStatementSPI

public class EPStatementImpl extends Object implements EPStatementSPI
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a listener that observes events.
    void
    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.
    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>
    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
     
    void
    Remove all listeners.
    void
    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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      protected final StatementResultServiceImpl statementResultService
    • parentView

      protected com.espertech.esper.common.internal.view.core.Viewable parentView
    • destroyed

      protected boolean destroyed
  • Constructor Details

  • Method Details

    • addListener

      public void addListener(UpdateListener listener)
      Description copied from interface: EPListenable
      Add a listener that observes events.
      Specified by:
      addListener in interface EPListenable
      Parameters:
      listener - to add
    • getStatementId

      public int getStatementId()
      Description copied from interface: EPStatementSPI
      Returns the statement id.
      Specified by:
      getStatementId in interface EPStatementSPI
      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 interface EPStatementSPI
      Returns:
      statement context
    • getName

      public String getName()
      Description copied from interface: EPStatement
      Returns the statement name.
      Specified by:
      getName in interface EPStatement
      Returns:
      statement name
    • getDispatchChildView

      public com.espertech.esper.common.internal.statement.dispatch.UpdateDispatchView getDispatchChildView()
      Specified by:
      getDispatchChildView in interface EPStatementSPI
    • isDestroyed

      public boolean isDestroyed()
      Description copied from interface: EPStatement
      Returns true if the statement has been undeployed.
      Specified by:
      isDestroyed in interface EPStatement
      Returns:
      true for undeployed statements, false for deployed statements.
    • recoveryUpdateListeners

      public void recoveryUpdateListeners(EPStatementListenerSet listenerSet)
      Specified by:
      recoveryUpdateListeners in interface EPStatementSPI
    • 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 interface EPStatement
      Returns:
      event type of events the iterator returns and that listeners receive
    • getAnnotations

      public Annotation[] 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 interface EPStatement
      Returns:
      annotations or a zero-length array if no annotaions have been specified.
    • iterator

      public Iterator<com.espertech.esper.common.client.EventBean> 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 interface EPIterable
      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 interface EPIterable
      Returns:
      safe iterator; NOTE: Must use the close method to close the safe iterator, preferably in a finally block
    • removeListener

      public void removeListener(UpdateListener listener)
      Description copied from interface: EPListenable
      Remove a listener that observes events.
      Specified by:
      removeListener in interface EPListenable
      Parameters:
      listener - to remove
    • removeAllListeners

      public void removeAllListeners()
      Description copied from interface: EPListenable
      Remove all listeners.
      Specified by:
      removeAllListeners in interface EPListenable
    • getUpdateListeners

      public Iterator<UpdateListener> 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 interface EPListenable
      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 interface EPStatementSPI
      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 interface EPStatementSPI
      Parameters:
      viewable - is the statement viewable
    • setDestroyed

      public void setDestroyed()
      Specified by:
      setDestroyed in interface EPStatementSPI
    • 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 interface EPIterable
      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 interface EPIterable
      Parameters:
      selector - selects context partitions to consider
      Returns:
      safe iterator
    • getDeploymentId

      public String getDeploymentId()
      Description copied from interface: EPStatement
      Returns the deployment id.
      Specified by:
      getDeploymentId in interface EPStatement
      Returns:
      deployment id
    • setSubscriber

      public void setSubscriber(Object subscriber)
      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 interface EPStatement
      Parameters:
      subscriber - to attach, or null to remove the previously set subscriber
    • setSubscriber

      public void setSubscriber(Object subscriber, String methodName)
      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 interface EPStatement
      Parameters:
      subscriber - to attach, or null to remove the previously set subscriber
      methodName - the name of the method to invoke, or null for the "update" method
    • getSubscriber

      public Object getSubscriber()
      Description copied from interface: EPStatement
      Returns the current subscriber instance that receives statement results.
      Specified by:
      getSubscriber in interface EPStatement
      Returns:
      subscriber object, or null to indicate that no subscriber is attached
    • getProperty

      public Object getProperty(com.espertech.esper.common.client.util.StatementProperty field)
      Description copied from interface: EPStatement
      Returns a statement property value.
      Specified by:
      getProperty in interface EPStatement
      Parameters:
      field - statement property value
      Returns:
      property or null if not set
    • addListenerWithReplay

      public void addListenerWithReplay(UpdateListener listener)
      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 interface EPListenable
      Parameters:
      listener - to add
    • getUserObjectCompileTime

      public Object 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 interface EPStatement
      Returns:
      user object or null if none defined
    • getUserObjectRuntime

      public Object 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 interface EPStatement
      Returns:
      user object or null if none defined
    • checkDestroyed

      protected void checkDestroyed()