net.esper.core
Class EPRuntimeImpl

java.lang.Object
  extended by net.esper.core.EPRuntimeImpl
All Implemented Interfaces:
EPRuntime, InternalEventRouter, TimerCallback

public class EPRuntimeImpl
extends Object
implements EPRuntime, TimerCallback, InternalEventRouter

Implements runtime interface. Also accepts timer callbacks for synchronizing time events with regular events sent in.


Constructor Summary
EPRuntimeImpl(EPServicesContext services, ManagedReadWriteLock eventProcessingRWLock)
          Constructor.
 
Method Summary
 void addEmittedListener(EmittedListener listener, String channel)
          Register an object that listens for events emitted from the event stream processing runtime on the specified channel.
 void clearEmittedListeners()
          Deregister all emitted event listeners.
 void emit(Object object)
          Emit an event object to any registered EmittedListener instances listening to the default channel.
 void emit(Object object, String channel)
          Emit an event object to any registered EmittedListener instances on the specified channel.
 int getNumEventsEmitted()
          Number of events emitted over the lifetime of the event stream processing runtime.
 int getNumEventsReceived()
          Number of events received over the lifetime of the event stream processing runtime.
 void route(EventBean event)
          Route the event such that the event is processed as required.
 void route(Object event)
          Route the event object back to the event stream processing runtime for internal dispatching.
 void sendEvent(Map map, String eventTypeAlias)
          Send a map containing event property values to the event stream processing runtime.
 void sendEvent(Node document)
          Send an event represented by a DOM node to the event stream processing runtime.
 void sendEvent(Object event)
          Send an event represented by a plain Java object to the event stream processing runtime.
 void timerCallback()
          Invoked by the internal clocking service at regular intervals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EPRuntimeImpl

public EPRuntimeImpl(EPServicesContext services,
                     ManagedReadWriteLock eventProcessingRWLock)
Constructor.

Parameters:
services - - references to services
eventProcessingRWLock - - lock for statement create/start/stop across engine instance competing with events
Method Detail

timerCallback

public void timerCallback()
Description copied from interface: TimerCallback
Invoked by the internal clocking service at regular intervals.

Specified by:
timerCallback in interface TimerCallback

sendEvent

public void sendEvent(Object event)
               throws EPException
Description copied from interface: EPRuntime
Send an event represented by a plain Java object to the event stream processing runtime.

Use the route method for sending events into the runtime from within UpdateListener code.

Specified by:
sendEvent in interface EPRuntime
Parameters:
event - is the event to sent to the runtime
Throws:
EPException - is thrown when the processing of the event lead to an error

sendEvent

public void sendEvent(Node document)
               throws EPException
Description copied from interface: EPRuntime
Send an event represented by a DOM node to the event stream processing runtime.

Use the route method for sending events into the runtime from within UpdateListener code.

Specified by:
sendEvent in interface EPRuntime
Parameters:
document - is the DOM node as an event
Throws:
EPException - is thrown when the processing of the event lead to an error

sendEvent

public void sendEvent(Map map,
                      String eventTypeAlias)
               throws EPException
Description copied from interface: EPRuntime
Send a map containing event property values to the event stream processing runtime.

Use the route method for sending events into the runtime from within UpdateListener code.

Specified by:
sendEvent in interface EPRuntime
Parameters:
map - - map that contains event property values. Keys are expected to be of type String while values can be of any type. Keys and values should match those declared via Configuration for the given eventTypeAlias.
eventTypeAlias - - the alias for the (property name, property type) information for this map
Throws:
EPException - - when the processing of the event leads to an error

getNumEventsReceived

public int getNumEventsReceived()
Description copied from interface: EPRuntime
Number of events received over the lifetime of the event stream processing runtime.

Specified by:
getNumEventsReceived in interface EPRuntime
Returns:
number of events received

getNumEventsEmitted

public int getNumEventsEmitted()
Description copied from interface: EPRuntime
Number of events emitted over the lifetime of the event stream processing runtime.

Specified by:
getNumEventsEmitted in interface EPRuntime
Returns:
number of events emitted

route

public void route(Object event)
Description copied from interface: EPRuntime
Route the event object back to the event stream processing runtime for internal dispatching. The route event is processed just like it was sent to the runtime, that is any active expressions seeking that event receive it. The routed event has priority over other events sent to the runtime. In a single-threaded application the routed event is processed before the next event is sent to the runtime through the EPRuntime.sendEvent method.

Specified by:
route in interface EPRuntime
Parameters:
event - to route internally for processing by the event stream processing runtime

route

public void route(EventBean event)
Description copied from interface: InternalEventRouter
Route the event such that the event is processed as required.

Specified by:
route in interface InternalEventRouter
Parameters:
event - to route

emit

public void emit(Object object)
Description copied from interface: EPRuntime
Emit an event object to any registered EmittedListener instances listening to the default channel.

Specified by:
emit in interface EPRuntime
Parameters:
object - to be emitted to the default channel

emit

public void emit(Object object,
                 String channel)
Description copied from interface: EPRuntime
Emit an event object to any registered EmittedListener instances on the specified channel. Event listeners listening to all channels as well as those listening to the specific channel are called. Supplying a null value in the channel has the same result as the emit(Object object) method.

Specified by:
emit in interface EPRuntime
Parameters:
object - to be emitted
channel - channel to emit the object to, or null if emitting to the default channel

addEmittedListener

public void addEmittedListener(EmittedListener listener,
                               String channel)
Description copied from interface: EPRuntime
Register an object that listens for events emitted from the event stream processing runtime on the specified channel. A null value can be supplied for the channel in which case the emit listener will be invoked for events emitted an any channel.

Specified by:
addEmittedListener in interface EPRuntime
Parameters:
listener - called when an event is emitted by the runtime.
channel - is the channel to add the listener to, a null value can be used to listen to events emitted on all channels

clearEmittedListeners

public void clearEmittedListeners()
Description copied from interface: EPRuntime
Deregister all emitted event listeners.

Specified by:
clearEmittedListeners in interface EPRuntime