Class CacheManagerEventListenerRegistry

  • All Implemented Interfaces:
    CacheManagerEventListener

    public class CacheManagerEventListenerRegistry
    extends java.lang.Object
    implements CacheManagerEventListener
    Registered listeners for registering and unregistering CacheManagerEventListeners and sending notifications to registrants.

    There is one of these per CacheManager. It is a composite listener.

    Since:
    1.3
    Version:
    $Id$
    Author:
    Greg Luck
    • Constructor Detail

      • CacheManagerEventListenerRegistry

        public CacheManagerEventListenerRegistry()
        Construct a new registry
    • Method Detail

      • registerListener

        public final boolean registerListener​(CacheManagerEventListener cacheManagerEventListener)
        Adds a listener to the notification service. No guarantee is made that listeners will be notified in the order they were added.
        Parameters:
        cacheManagerEventListener - the listener to add. Can be null, in which case nothing happens
        Returns:
        true if the listener is being added and was not already added
      • unregisterListener

        public final boolean unregisterListener​(CacheManagerEventListener cacheManagerEventListener)
        Removes a listener from the notification service.
        Parameters:
        cacheManagerEventListener - the listener to remove
        Returns:
        true if the listener was present
      • hasRegisteredListeners

        public boolean hasRegisteredListeners()
        Returns whether or not at least one cache manager event listeners has been registered.
        Returns:
        true if a one or more listeners have registered, otherwise false
      • getRegisteredListeners

        public java.util.Set getRegisteredListeners()
        Gets a Set of the listeners registered to this class
        Returns:
        a set of type CacheManagerEventListener
      • dispose

        public 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.
        Specified by:
        dispose in interface CacheManagerEventListener
      • notifyCacheAdded

        public void notifyCacheAdded​(java.lang.String cacheName)
        Called immediately after a cache has been added and activated.

        Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized method on CacheManager from this method will cause a deadlock.

        Note that activation will also cause a CacheEventListener status change notification from Status.STATUS_UNINITIALISED to Status.STATUS_ALIVE. Care should be taken on processing that notification because:

        • the cache will not yet be accessible from the CacheManager.
        • the addCaches methods which cause this notification are synchronized on the CacheManager. An attempt to call CacheManager.getEhcache(String) will cause a deadlock.
        The calling method will block until this method returns.

        Specified by:
        notifyCacheAdded in interface CacheManagerEventListener
        Parameters:
        cacheName - the name of the Cache the operation relates to
        See Also:
        CacheEventListener
      • notifyCacheRemoved

        public void notifyCacheRemoved​(java.lang.String cacheName)
        Called immediately after a cache has been disposed and removed. The calling method will block until this method returns.

        Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized method on CacheManager from this method will cause a deadlock.

        Note that a CacheEventListener status changed will also be triggered. Any attempt from that notification to access CacheManager will also result in a deadlock.

        Specified by:
        notifyCacheRemoved in interface CacheManagerEventListener
        Parameters:
        cacheName - the name of the Cache the operation relates to
      • toString

        public java.lang.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.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the object.