org.ehcache.core.events
Class CacheEventDispatcherImpl<K,V>

java.lang.Object
  extended by org.ehcache.core.events.CacheEventDispatcherImpl<K,V>
All Implemented Interfaces:
CacheEventDispatcher<K,V>, ConfigurationChangeSupport

public class CacheEventDispatcherImpl<K,V>
extends java.lang.Object
implements CacheEventDispatcher<K,V>

Per-cache component that manages cache event listener registrations, and provides event delivery based on desired firing mode and ordering, for specified event types.

Note on event ordering guarantees:
onEvent(CacheEvent) is assumed to be called within a key-based lock scope. If that is not the case, this facility has no means of maintaining event ordering consistent with source of such events. That is - listeners registered to receive events in the order they occurred in underlying store may be invoked in an order inconsistent with actual ordering of corresponding operations on said store.

Conversely, sending events to this service inside lock scope, when there are no registered listeners interested in ordered event delivery is harmless, i.e. event delivery to unordered listeners will still occur.


Constructor Summary
CacheEventDispatcherImpl(java.util.concurrent.ExecutorService unOrderedExectuor, java.util.concurrent.ExecutorService orderedExecutor)
           
 
Method Summary
 void deregisterCacheEventListener(CacheEventListener<? super K,? super V> listener)
          Allows for deregistering of a previously registered CacheEventListener instance
 java.util.List<CacheConfigurationChangeListener> getConfigurationChangeListeners()
          get the List CacheConfigurationChangeListener defined in the Store
 void onEvent(CacheEvent<K,V> event)
           
 void registerCacheEventListener(CacheEventListener<? super K,? super V> listener, EventOrdering ordering, EventFiring firing, java.util.EnumSet<EventType> forEventTypes)
          Allows for registering CacheEventListener on the cache
 void setListenerSource(Cache<K,V> source)
           
 void setStoreEventSource(StoreEventSource<K,V> eventSource)
          Sets StoreEventSource to enable eventing
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheEventDispatcherImpl

public CacheEventDispatcherImpl(java.util.concurrent.ExecutorService unOrderedExectuor,
                                java.util.concurrent.ExecutorService orderedExecutor)
Method Detail

registerCacheEventListener

public void registerCacheEventListener(CacheEventListener<? super K,? super V> listener,
                                       EventOrdering ordering,
                                       EventFiring firing,
                                       java.util.EnumSet<EventType> forEventTypes)
Allows for registering CacheEventListener on the cache

Specified by:
registerCacheEventListener in interface CacheEventDispatcher<K,V>
Parameters:
listener - the listener instance to register
ordering - the EventOrdering to invoke this listener
firing - the EventFiring to invoke this listener
forEventTypes - the EventType to notify this listener of
Throws:
java.lang.IllegalStateException - if the listener is already registered

deregisterCacheEventListener

public void deregisterCacheEventListener(CacheEventListener<? super K,? super V> listener)
Allows for deregistering of a previously registered CacheEventListener instance

Specified by:
deregisterCacheEventListener in interface CacheEventDispatcher<K,V>
Parameters:
listener - the listener to deregister
Throws:
java.lang.IllegalStateException - if the listener isn't already registered

shutdown

public void shutdown()
Specified by:
shutdown in interface CacheEventDispatcher<K,V>

setListenerSource

public void setListenerSource(Cache<K,V> source)
Specified by:
setListenerSource in interface CacheEventDispatcher<K,V>

onEvent

public void onEvent(CacheEvent<K,V> event)

getConfigurationChangeListeners

public java.util.List<CacheConfigurationChangeListener> getConfigurationChangeListeners()
Description copied from interface: ConfigurationChangeSupport
get the List CacheConfigurationChangeListener defined in the Store

Specified by:
getConfigurationChangeListeners in interface ConfigurationChangeSupport
Returns:
a list of CacheConfigurationChangeListener

setStoreEventSource

public void setStoreEventSource(StoreEventSource<K,V> eventSource)
Sets StoreEventSource to enable eventing

Specified by:
setStoreEventSource in interface CacheEventDispatcher<K,V>
Parameters:
eventSource -