net.sf.ehcache.event

Class RegisteredEventListeners

public final class RegisteredEventListeners extends Object

Registered listeners for registering and unregistering CacheEventListeners and multicasting notifications to registrants.

There is one of these per Cache

Version: $Id: RegisteredEventListeners.java 51 2006-04-24 09:21:10Z gregluck $

Author: Greg Luck

Constructor Summary
RegisteredEventListeners(Cache cache)
Constructs a new notification service
Method Summary
voiddispose()
Tell listeners to dispose themselves.
SetgetCacheEventListeners()
Gets a list of the listeners registered to this class
voidnotifyElementExpiry(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has expired
voidnotifyElementPut(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was put into the cache
voidnotifyElementRemoved(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was removed
voidnotifyElementUpdated(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element in the cache was updated
booleanregisterListener(CacheEventListener cacheEventListener)
Adds a listener to the notification service.
StringtoString()
Returns a string representation of the object.
booleanunregisterListener(CacheEventListener cacheEventListener)
Removes a listener from the notification service.

Constructor Detail

RegisteredEventListeners

public RegisteredEventListeners(Cache cache)
Constructs a new notification service

Parameters: cache

Method Detail

dispose

public final void dispose()
Tell listeners to dispose themselves. Because this method is only ever called from a synchronized cache method, it does not itself need to be synchronized.

getCacheEventListeners

public final Set getCacheEventListeners()
Gets a list of the listeners registered to this class

Returns: a list of type CacheEventListener

notifyElementExpiry

public final void notifyElementExpiry(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element has expired

Parameters: element remoteEvent whether the event came from a remote cache peer

See Also: CacheEventListener

notifyElementPut

public final void notifyElementPut(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was put into the cache

Parameters: element remoteEvent whether the event came from a remote cache peer

See Also: notifyElementPut

notifyElementRemoved

public final void notifyElementRemoved(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element was removed

Parameters: element remoteEvent whether the event came from a remote cache peer

See Also: CacheEventListener

notifyElementUpdated

public final void notifyElementUpdated(Element element, boolean remoteEvent)
Notifies all registered listeners, in no guaranteed order, that an element in the cache was updated

Parameters: element remoteEvent whether the event came from a remote cache peer

See Also: notifyElementPut

registerListener

public final boolean registerListener(CacheEventListener cacheEventListener)
Adds a listener to the notification service. No guarantee is made that listeners will be notified in the order they were added.

Parameters: cacheEventListener

Returns: true if the listener is being added and was not already added

toString

public final String toString()
Returns a string representation of the object. In general, the 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.

Returns: a string representation of the object.

unregisterListener

public final boolean unregisterListener(CacheEventListener cacheEventListener)
Removes a listener from the notification service.

Parameters: cacheEventListener

Returns: true if the listener was present