org.opencredo.esper
Class EsperStatement

java.lang.Object
  extended by org.opencredo.esper.EsperStatement
All Implemented Interfaces:
EsperStatementOperations

public class EsperStatement
extends java.lang.Object
implements EsperStatementOperations

Implements a set of convenient Template operations around a native Esper Statement. Support both the push (via listener or subscriber) or pull (via the template methods) operations to retrieve results from the associated statement. For more information on push and pull operations on esper statements, see http://esper.codehaus.org/esper-3.3.0/doc/reference/en/html/api.html#api-receive-results

Author:
Russ Miles (russ.miles@opencredo.com)

Constructor Summary
EsperStatement(java.lang.String epl)
           
 
Method Summary
 void addListener(com.espertech.esper.client.UpdateListener listener)
          Adds an {@link UpdateListener) to the statement to support the 'push' mode of retrieving results.
<T> java.util.List<T>
concurrentSafeQuery(ParameterizedEsperRowMapper<T> rm)
          Performs a concurrency safe 'pull' to retrieve query filtered results from the esper statement.
<T> T
concurrentSafeQueryForObject(ParameterizedEsperRowMapper<T> rm)
          Performs a concurrency safe 'pull' to retrieve query filtered results from the esper statement.
<T> java.util.List<T>
concurrentUnsafeQuery(ParameterizedEsperRowMapper<T> rm)
          Performs a concurrency unsafe 'pull' (i.e.
<T> T
concurrentUnsafeQueryForObject(ParameterizedEsperRowMapper<T> rm)
          Performs a concurrency unsafe 'pull' (i.e.
 void doWithNativeEPStatement(NativeEPStatementCallback callback)
          Provides a mechanism by which to access the underlying esper API
 java.lang.String getEPL()
           
 java.util.Set<com.espertech.esper.client.UpdateListener> getListeners()
           
 com.espertech.esper.client.EPStatementState getState()
           
 void setListeners(java.util.Set<com.espertech.esper.client.UpdateListener> listeners)
           
 void setSubscriber(java.lang.Object subscriber)
           
 void start()
          Starts events being collated according to the statement's filter query
 void stop()
          Stops the underlying native statement from applying its filter query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EsperStatement

public EsperStatement(java.lang.String epl)
Method Detail

getEPL

public java.lang.String getEPL()

getState

public com.espertech.esper.client.EPStatementState getState()

start

public void start()
Starts events being collated according to the statement's filter query


stop

public void stop()
Stops the underlying native statement from applying its filter query.


doWithNativeEPStatement

public void doWithNativeEPStatement(NativeEPStatementCallback callback)
Provides a mechanism by which to access the underlying esper API

Parameters:
callback - used to pass access to the underlying esper API resources

setListeners

public void setListeners(java.util.Set<com.espertech.esper.client.UpdateListener> listeners)

getListeners

public java.util.Set<com.espertech.esper.client.UpdateListener> getListeners()

setSubscriber

public void setSubscriber(java.lang.Object subscriber)

addListener

public void addListener(com.espertech.esper.client.UpdateListener listener)
Adds an {@link UpdateListener) to the statement to support the 'push' mode of retrieving results.

Parameters:
listener - The listener to be invoked when appropriate results according to the EPL filter query.

concurrentSafeQuery

public <T> java.util.List<T> concurrentSafeQuery(ParameterizedEsperRowMapper<T> rm)
Description copied from interface: EsperStatementOperations
Performs a concurrency safe 'pull' to retrieve query filtered results from the esper statement. The supplied ParameterizedEsperRowMapper is then used to populate the objects that are then collected together and returned as a List.

Specified by:
concurrentSafeQuery in interface EsperStatementOperations
Parameters:
rm - the ParameterizedEsperRowMapper to use for result mapping
Returns:
a list containing all the objects mapped from the query results

concurrentSafeQueryForObject

public <T> T concurrentSafeQueryForObject(ParameterizedEsperRowMapper<T> rm)
Description copied from interface: EsperStatementOperations
Performs a concurrency safe 'pull' to retrieve query filtered results from the esper statement. Be aware that this operation will lock the underlying esper statement resources while executing.

Specified by:
concurrentSafeQueryForObject in interface EsperStatementOperations
Parameters:
rm - the ParameterizedEsperRowMapper to use for result mapping
Returns:
the single mapped object

concurrentUnsafeQuery

public <T> java.util.List<T> concurrentUnsafeQuery(ParameterizedEsperRowMapper<T> rm)
Description copied from interface: EsperStatementOperations
Performs a concurrency unsafe 'pull' (i.e. should only be used in a single threaded environment) to retrieve query filtered results from the esper statement. The supplied ParameterizedEsperRowMapper is then used to populate the objects that are then collected together and returned as a List.

Specified by:
concurrentUnsafeQuery in interface EsperStatementOperations
Parameters:
rm - the ParameterizedEsperRowMapper to use for result mapping
Returns:
a list containing all the objects mapped from the query results

concurrentUnsafeQueryForObject

public <T> T concurrentUnsafeQueryForObject(ParameterizedEsperRowMapper<T> rm)
Description copied from interface: EsperStatementOperations
Performs a concurrency unsafe 'pull' (i.e. should only be used in a single threaded environment) to retrieve a query filtered result from the esper statement. The supplied ParameterizedEsperRowMapper is then used to populate the object that is returned.

Specified by:
concurrentUnsafeQueryForObject in interface EsperStatementOperations
Parameters:
rm - the ParameterizedEsperRowMapper to use for result mapping
Returns:
the mapped object


Copyright © 2010. All Rights Reserved.