org.opencredo.esper
Class EsperTemplate

java.lang.Object
  extended by org.opencredo.esper.EsperTemplate
All Implemented Interfaces:
EsperTemplateOperations
Direct Known Subclasses:
EsperTemplateBean

public class EsperTemplate
extends java.lang.Object
implements EsperTemplateOperations

The main workhorse of Esper. The template is configured with a set of statements that query the flow of events. Each statement is then associated with a number of listeners who will be notified when there is a result from the statement.

Once setup the template is then used to inform esper of any events of interest by calling sendEvent(Object).

Author:
Russ Miles (russ.miles@opencredo.com), Jonas Partner (jonas.partner@opencredo.com)

Constructor Summary
EsperTemplate()
           
 
Method Summary
 void addStatement(EsperStatement statement)
          Adds an EsperStatement to the template.
 void cleanup()
          Deallocated all resources associated with this template when it is finished with.
 com.espertech.esper.client.EPRuntime getEsperNativeRuntime()
          Retrieve the configured esper native runtime.
 java.lang.String getName()
           
 java.util.Set<EsperStatement> getStatements()
          Return the currently configured and registered set of EsperStatement objects.
 void initialize()
          Sets up and allocated all resources associated with this template prior to its use.
 void sendEvent(java.lang.Object event)
          Instructs the template to send an event to Esper.
 void setConfiguration(org.springframework.core.io.Resource configuration)
          Set the location of the XML Esper configuration resource.
 void setName(java.lang.String name)
          Sets the name used to identify this template and its resources within Esper.
 void setStatements(java.util.Set<EsperStatement> statements)
          Add a collection of EsperStatement to the template.
 void setUnmatchedListener(com.espertech.esper.client.UnmatchedListener unmatchedListener)
          Specify the listener that should be notified of any unmatched events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EsperTemplate

public EsperTemplate()
Method Detail

setName

public void setName(java.lang.String name)
Description copied from interface: EsperTemplateOperations
Sets the name used to identify this template and its resources within Esper.

Specified by:
setName in interface EsperTemplateOperations
Parameters:
name - The name associated with this template

getName

public java.lang.String getName()

setStatements

public void setStatements(java.util.Set<EsperStatement> statements)
Description copied from interface: EsperTemplateOperations
Add a collection of EsperStatement to the template.

Specified by:
setStatements in interface EsperTemplateOperations

setConfiguration

public void setConfiguration(org.springframework.core.io.Resource configuration)
Description copied from interface: EsperTemplateOperations
Set the location of the XML Esper configuration resource.

Specified by:
setConfiguration in interface EsperTemplateOperations

setUnmatchedListener

public void setUnmatchedListener(com.espertech.esper.client.UnmatchedListener unmatchedListener)
Description copied from interface: EsperTemplateOperations
Specify the listener that should be notified of any unmatched events.

Specified by:
setUnmatchedListener in interface EsperTemplateOperations
Parameters:
unmatchedListener - The listener that is notified of events that are not matched

getEsperNativeRuntime

public com.espertech.esper.client.EPRuntime getEsperNativeRuntime()
Description copied from interface: EsperTemplateOperations
Retrieve the configured esper native runtime.

Specified by:
getEsperNativeRuntime in interface EsperTemplateOperations
Returns:
The current esper native runtime

getStatements

public java.util.Set<EsperStatement> getStatements()
Description copied from interface: EsperTemplateOperations
Return the currently configured and registered set of EsperStatement objects.

Specified by:
getStatements in interface EsperTemplateOperations
Returns:
a set of configured EsperStatement objects.

addStatement

public void addStatement(EsperStatement statement)
Description copied from interface: EsperTemplateOperations
Adds an EsperStatement to the template.

Specified by:
addStatement in interface EsperTemplateOperations
Parameters:
statement - The EsperStatement to add to the template.

sendEvent

public void sendEvent(java.lang.Object event)
               throws InvalidEsperConfigurationException
Description copied from interface: EsperTemplateOperations
Instructs the template to send an event to Esper. Events are then used to satisfy statements, which then alert listeners.

Specified by:
sendEvent in interface EsperTemplateOperations
Parameters:
event - The event that Esper is to be informed of.
Throws:
InvalidEsperConfigurationException - thrown if any runtime configuration problems occur

initialize

public void initialize()
                throws InvalidEsperConfigurationException
Description copied from interface: EsperTemplateOperations
Sets up and allocated all resources associated with this template prior to its use. Initializes the Esper service provider with the provided statements and associated listeners. Works together with the cleanup() operation, which in turn frees up the resources used by this template.

Specified by:
initialize in interface EsperTemplateOperations
Throws:
InvalidEsperConfigurationException - thrown if any configuration errors have been made

cleanup

public void cleanup()
Description copied from interface: EsperTemplateOperations
Deallocated all resources associated with this template when it is finished with. Works together with the initialize() operation.

Specified by:
cleanup in interface EsperTemplateOperations


Copyright © 2010. All Rights Reserved.