com.hammurapi.eventbus.local
Class LocalSimpleMatcher<E,P extends Comparable<P>,C,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

Show UML class diagram
java.lang.Object
  extended by com.hammurapi.eventbus.local.LocalSimpleMatcher<E,P,C,S>
Type Parameters:
E -
P -
C -
K -
H -
S -
All Implemented Interfaces:
LocalMatcher<E,P,C,S>, Matcher<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S>

public class LocalSimpleMatcher<E,P extends Comparable<P>,C,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>
extends Object
implements LocalMatcher<E,P,C,S>

This matcher does matching in a straightforward way - it evaluates handler predicates sequentially, it does not cache extracted values, does not optimize event joins, and does not use executor service. The purpose of this matcher is to help with debugging and troubleshooting of handler/predicate logic and to be a baseline of matching performance. This matcher doesn't support snapshots.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.hammurapi.eventbus.Matcher
Matcher.HandlerManager<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>
 
Field Summary
protected  Collection<EventHandlerWrapper<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S>> wrappers
           
 
Constructor Summary
LocalSimpleMatcher()
           
 
Method Summary
 Long addHandler(EventHandler<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S> eventHandler)
          Adds handler to the matcher.
protected  com.hammurapi.eventbus.local.LocalSimpleMatcher.HandleJoiner createJoiner(EventHandler<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S> eventHandler, Long registrationKey)
           
protected  ReadWriteLock getLock()
          Lock for the inference network.
 void manageHandlers(Matcher.HandlerManager<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> handlerManager)
          This method is used for batch live updates of matcher handlers.
 Iterable<EventHandlerWrapper<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S>> match(E event, ExecutorService executorService)
           
protected  Long nextId()
           
 void removeHandlers(Iterable<Long> keys)
           
 void reset()
          Resets handler's state.
 void setEventBus(EventBus<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> bus)
          This method is invoked by the bus to provide a reference to self.
 void takeSnapshot(AbstractEventBus.Snapshot<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> snapshot)
          Takes matcher snapshot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wrappers

protected Collection<EventHandlerWrapper<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>> wrappers
Constructor Detail

LocalSimpleMatcher

public LocalSimpleMatcher()
Method Detail

getLock

protected ReadWriteLock getLock()
Lock for the inference network.

Returns:

nextId

protected Long nextId()

addHandler

public Long addHandler(EventHandler<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S> eventHandler)
Description copied from interface: Matcher
Adds handler to the matcher.

Specified by:
addHandler in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>
Returns:

match

public Iterable<EventHandlerWrapper<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S>> match(E event,
                                                                                             ExecutorService executorService)
Specified by:
match in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>
executorService - Executor service to use for parallel matching.
Returns:
Handlers matching the event ordered by priority.

takeSnapshot

public void takeSnapshot(AbstractEventBus.Snapshot<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> snapshot)
Description copied from interface: Matcher
Takes matcher snapshot.

Specified by:
takeSnapshot in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

removeHandlers

public void removeHandlers(Iterable<Long> keys)
Specified by:
removeHandlers in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

reset

public void reset()
Description copied from interface: Matcher
Resets handler's state.

Specified by:
reset in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

manageHandlers

public void manageHandlers(Matcher.HandlerManager<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> handlerManager)
Description copied from interface: Matcher
This method is used for batch live updates of matcher handlers. The method acquires matcher write lock, then invokes matcher manager's manageHandlers() method within the lock and then releases the lock. Therefore, matcher structure update is executed as one logical unit.

Specified by:
manageHandlers in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

setEventBus

public void setEventBus(EventBus<E,P,C,Long,AbstractEventBus.Handle<E,P,C,Long>,S> bus)
Description copied from interface: Matcher
This method is invoked by the bus to provide a reference to self.

Specified by:
setEventBus in interface Matcher<E,P extends Comparable<P>,C,Long,AbstractEventBus.Handle<E,P extends Comparable<P>,C,Long>,S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>>

createJoiner

protected com.hammurapi.eventbus.local.LocalSimpleMatcher.HandleJoiner createJoiner(EventHandler<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S> eventHandler,
                                                                                    Long registrationKey)