public class RegisteredEventListeners
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
RegisteredEventListeners.ElementCreationCallback
Callback interface for creating elements to pass to registered listeners.
|
private static class |
RegisteredEventListeners.Event
Event callback types
|
private static class |
RegisteredEventListeners.ListenerWrapper
Combine a Listener and its NotificationScope.
|
Modifier and Type | Field and Description |
---|---|
private Ehcache |
cache |
private java.util.Set<RegisteredEventListeners.ListenerWrapper> |
cacheEventListeners
A Set of CacheEventListeners keyed by listener instance.
|
private java.util.concurrent.atomic.AtomicLong |
elementsEvictedCounter |
private java.util.concurrent.atomic.AtomicLong |
elementsExpiredCounter |
private java.util.concurrent.atomic.AtomicLong |
elementsPutCounter |
private java.util.concurrent.atomic.AtomicLong |
elementsRemoveAllCounter |
private java.util.concurrent.atomic.AtomicLong |
elementsRemovedCounter |
private java.util.concurrent.atomic.AtomicLong |
elementsUpdatedCounter |
private java.util.concurrent.atomic.AtomicBoolean |
hasReplicator |
private CacheStoreHelper |
helper |
Constructor and Description |
---|
RegisteredEventListeners(Ehcache cache)
Constructs a new notification service
|
Modifier and Type | Method and Description |
---|---|
void |
clearCounters()
Clears all event counters
|
void |
dispose()
Tell listeners to dispose themselves.
|
java.util.Set<CacheEventListener> |
getCacheEventListeners()
Gets a copy of the set of the listeners registered to this class
|
long |
getElementsEvictedCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
long |
getElementsExpiredCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
long |
getElementsPutCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
long |
getElementsRemoveAllCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
long |
getElementsRemovedCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
long |
getElementsUpdatedCounter()
Gets the number of events, irrespective of whether there are any registered listeners.
|
FrontEndCacheTier |
getFrontEndCacheTier()
Returns the
FrontEndCacheTier this RegisteredEventListeners is backing, or null if the cache isn't backed by one |
boolean |
hasCacheEventListeners()
Returns whether or not at least one cache event listeners has been registered.
|
boolean |
hasCacheReplicators()
Determines whether any registered listeners are CacheReplicators.
|
private void |
internalNotifyElementEvicted(Element element,
RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent) |
private void |
internalNotifyElementExpiry(Element element,
RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent) |
private void |
internalNotifyElementPut(Element element,
RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent) |
private void |
internalNotifyElementRemoved(Element element,
RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent) |
private void |
internalNotifyElementUpdated(Element element,
RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent) |
private void |
invokeListener(CacheEventListener listener,
Element element,
RegisteredEventListeners.ElementCreationCallback callback,
RegisteredEventListeners.Event eventType) |
private static boolean |
isCircularNotification(boolean remoteEvent,
CacheEventListener cacheEventListener)
CacheReplicators should not be notified of events received remotely, as this would cause
a circular notification
|
void |
notifyElementEvicted(Element element,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has been
evicted from the cache
|
void |
notifyElementEvicted(RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has been
evicted from the cache
|
void |
notifyElementExpiry(Element element,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has expired
|
void |
notifyElementExpiry(RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has expired
|
void |
notifyElementPut(Element element,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was put into the cache
|
void |
notifyElementPut(RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was put into the cache
|
void |
notifyElementRemoved(Element element,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was removed
|
void |
notifyElementRemoved(RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was removed
|
void |
notifyElementUpdated(Element element,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element in the cache was updated
|
void |
notifyElementUpdated(RegisteredEventListeners.ElementCreationCallback callback,
boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element in the cache was updated
|
private void |
notifyListener(CacheEventListener listener,
Element element,
RegisteredEventListeners.Event eventType) |
void |
notifyRemoveAll(boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that removeAll
has been called and all elements cleared
|
boolean |
registerListener(CacheEventListener cacheEventListener)
Adds a listener to the notification service.
|
boolean |
registerListener(CacheEventListener cacheEventListener,
NotificationScope scope)
Adds a listener to the notification service.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
boolean |
unregisterListener(CacheEventListener cacheEventListener)
Removes a listener from the notification service.
|
private final java.util.Set<RegisteredEventListeners.ListenerWrapper> cacheEventListeners
CacheEventListener
private final Ehcache cache
private final java.util.concurrent.atomic.AtomicBoolean hasReplicator
private final java.util.concurrent.atomic.AtomicLong elementsRemovedCounter
private final java.util.concurrent.atomic.AtomicLong elementsPutCounter
private final java.util.concurrent.atomic.AtomicLong elementsUpdatedCounter
private final java.util.concurrent.atomic.AtomicLong elementsExpiredCounter
private final java.util.concurrent.atomic.AtomicLong elementsEvictedCounter
private final java.util.concurrent.atomic.AtomicLong elementsRemoveAllCounter
private final CacheStoreHelper helper
public RegisteredEventListeners(Ehcache cache)
cache
- public final void notifyElementRemoved(Element element, boolean remoteEvent) throws CacheException
element
- remoteEvent
- whether the event came from a remote cache peerCacheException
CacheEventListener.notifyElementRemoved(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
public final void notifyElementRemoved(RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent) throws CacheException
callback
- remoteEvent
- whether the event came from a remote cache peerCacheException
CacheEventListener.notifyElementRemoved(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
private void internalNotifyElementRemoved(Element element, RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
public final void notifyElementPut(Element element, boolean remoteEvent) throws CacheException
element
- remoteEvent
- whether the event came from a remote cache peerCacheException
CacheEventListener.notifyElementPut(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)
public final void notifyElementPut(RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent) throws CacheException
callback
- remoteEvent
- whether the event came from a remote cache peerCacheException
CacheEventListener.notifyElementPut(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)
private void internalNotifyElementPut(Element element, RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
public final void notifyElementUpdated(Element element, boolean remoteEvent)
element
- remoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementPut(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)
public final void notifyElementUpdated(RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
callback
- remoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementPut(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)
private void internalNotifyElementUpdated(Element element, RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
public final void notifyElementExpiry(Element element, boolean remoteEvent)
element
- the Element to perform the notification onremoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementExpired(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
public final void notifyElementExpiry(RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
callback
- remoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementExpired(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
private void internalNotifyElementExpiry(Element element, RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
public final boolean hasCacheEventListeners()
public final void notifyElementEvicted(Element element, boolean remoteEvent)
element
- the Element to perform the notification onremoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementEvicted(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
public final void notifyElementEvicted(RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
callback
- remoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementEvicted(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
private void internalNotifyElementEvicted(Element element, RegisteredEventListeners.ElementCreationCallback callback, boolean remoteEvent)
private void invokeListener(CacheEventListener listener, Element element, RegisteredEventListeners.ElementCreationCallback callback, RegisteredEventListeners.Event eventType)
private void notifyListener(CacheEventListener listener, Element element, RegisteredEventListeners.Event eventType)
public final void notifyRemoveAll(boolean remoteEvent)
remoteEvent
- whether the event came from a remote cache peerCacheEventListener.notifyElementEvicted(net.sf.ehcache.Ehcache, net.sf.ehcache.Element)
private static boolean isCircularNotification(boolean remoteEvent, CacheEventListener cacheEventListener)
remoteEvent
- cacheEventListener
- public final boolean registerListener(CacheEventListener cacheEventListener)
cacheEventListener
- public final boolean registerListener(CacheEventListener cacheEventListener, NotificationScope scope)
listenForparameter.
cacheEventListener
- The listener to addscope
- The notification scopepublic final boolean unregisterListener(CacheEventListener cacheEventListener)
cacheEventListener
- public final boolean hasCacheReplicators()
public final java.util.Set<CacheEventListener> getCacheEventListeners()
CacheEventListener
public final void dispose()
public final java.lang.String toString()
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.toString
in class java.lang.Object
public void clearCounters()
public long getElementsRemovedCounter()
public long getElementsPutCounter()
public long getElementsUpdatedCounter()
public long getElementsExpiredCounter()
public long getElementsEvictedCounter()
public long getElementsRemoveAllCounter()
public FrontEndCacheTier getFrontEndCacheTier()
FrontEndCacheTier
this RegisteredEventListeners is backing, or null if the cache isn't backed by one