com.opensymphony.oscache.plugins.clustersupport
Class AbstractBroadcastingListener

java.lang.Object
  extended by com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
All Implemented Interfaces:
CacheEntryEventListener, CacheEventListener, LifecycleAware, EventListener
Direct Known Subclasses:
JavaGroupsBroadcastingListener, JMS10BroadcastingListener, JMSBroadcastingListener

public abstract class AbstractBroadcastingListener
extends Object
implements CacheEntryEventListener, LifecycleAware

Implementation of a CacheEntryEventListener. It broadcasts the flush events across a cluster to other listening caches. Note that this listener cannot be used in conjection with session caches.

Version:
$Revision: 254 $
Author:
Chris Miller

Field Summary
protected  Cache cache
           
protected static String CLUSTER_ORIGIN
          The name to use for the origin of cluster events.
 
Constructor Summary
AbstractBroadcastingListener()
           
 
Method Summary
 void cacheEntryAdded(CacheEntryEvent event)
          Event fired when an entry is added to the cache.
 void cacheEntryFlushed(CacheEntryEvent event)
          Event fired when an entry is flushed from the cache.
 void cacheEntryRemoved(CacheEntryEvent event)
          Event fired when an entry is removed from the cache.
 void cacheEntryUpdated(CacheEntryEvent event)
          Event fired when an entry is updated in the cache.
 void cacheFlushed(CachewideEvent event)
          An event that is fired when an entire cache gets flushed.
 void cacheGroupAdded(CacheGroupEvent event)
           
 void cacheGroupEntryAdded(CacheGroupEvent event)
           
 void cacheGroupEntryRemoved(CacheGroupEvent event)
           
 void cacheGroupFlushed(CacheGroupEvent event)
          Event fired when an entry is removed from the cache.
 void cacheGroupRemoved(CacheGroupEvent event)
           
 void cacheGroupUpdated(CacheGroupEvent event)
           
 void cachePatternFlushed(CachePatternEvent event)
          Event fired when a key pattern is flushed from the cache.
 void handleClusterNotification(ClusterNotification message)
          Handles incoming notification messages.
 void initialize(Cache cache, Config config)
          Called by the cache administrator class when a cache is instantiated.
protected abstract  void sendNotification(ClusterNotification message)
          Called when a cluster notification message is to be broadcast.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opensymphony.oscache.base.LifecycleAware
finialize
 

Field Detail

CLUSTER_ORIGIN

protected static final String CLUSTER_ORIGIN
The name to use for the origin of cluster events. Using this ensures events are not fired recursively back over the cluster.

See Also:
Constant Field Values

cache

protected Cache cache
Constructor Detail

AbstractBroadcastingListener

public AbstractBroadcastingListener()
Method Detail

cacheEntryFlushed

public void cacheEntryFlushed(CacheEntryEvent event)
Event fired when an entry is flushed from the cache. This broadcasts the flush message to any listening nodes on the network.

Specified by:
cacheEntryFlushed in interface CacheEntryEventListener

cacheGroupFlushed

public void cacheGroupFlushed(CacheGroupEvent event)
Event fired when an entry is removed from the cache. This broadcasts the remove method to any listening nodes on the network, as long as this event wasn't from a broadcast in the first place.

Specified by:
cacheGroupFlushed in interface CacheEntryEventListener

cachePatternFlushed

public void cachePatternFlushed(CachePatternEvent event)
Description copied from interface: CacheEntryEventListener
Event fired when a key pattern is flushed from the cache. Note that this event will not be fired if the pattern is null or an empty string, instead the flush request will silently be ignored.

Specified by:
cachePatternFlushed in interface CacheEntryEventListener

cacheFlushed

public void cacheFlushed(CachewideEvent event)
Description copied from interface: CacheEntryEventListener
An event that is fired when an entire cache gets flushed.

Specified by:
cacheFlushed in interface CacheEntryEventListener

cacheEntryAdded

public void cacheEntryAdded(CacheEntryEvent event)
Description copied from interface: CacheEntryEventListener
Event fired when an entry is added to the cache.

Specified by:
cacheEntryAdded in interface CacheEntryEventListener

cacheEntryRemoved

public void cacheEntryRemoved(CacheEntryEvent event)
Description copied from interface: CacheEntryEventListener
Event fired when an entry is removed from the cache.

Specified by:
cacheEntryRemoved in interface CacheEntryEventListener

cacheEntryUpdated

public void cacheEntryUpdated(CacheEntryEvent event)
Description copied from interface: CacheEntryEventListener
Event fired when an entry is updated in the cache.

Specified by:
cacheEntryUpdated in interface CacheEntryEventListener

cacheGroupAdded

public void cacheGroupAdded(CacheGroupEvent event)

cacheGroupEntryAdded

public void cacheGroupEntryAdded(CacheGroupEvent event)

cacheGroupEntryRemoved

public void cacheGroupEntryRemoved(CacheGroupEvent event)

cacheGroupRemoved

public void cacheGroupRemoved(CacheGroupEvent event)

cacheGroupUpdated

public void cacheGroupUpdated(CacheGroupEvent event)

initialize

public void initialize(Cache cache,
                       Config config)
                throws InitializationException
Called by the cache administrator class when a cache is instantiated.

Specified by:
initialize in interface LifecycleAware
Parameters:
cache - the cache instance that this listener is attached to.
config - The cache's configuration details. This allows the event handler to initialize itself based on the cache settings, and also to receive additional settings that were part of the cache configuration but that the cache itself does not care about. If you are using cache.properties for your configuration, simply add any additional properties that your event handler requires and they will be passed through in this parameter.
Throws:
InitializationException - thrown when there was a problem initializing the listener. The cache administrator will log this error and disable the listener.

handleClusterNotification

public void handleClusterNotification(ClusterNotification message)
Handles incoming notification messages. This method should be called by the underlying broadcasting implementation when a message is received from another node in the cluster.

Parameters:
message - The incoming cluster notification message object.

sendNotification

protected abstract void sendNotification(ClusterNotification message)
Called when a cluster notification message is to be broadcast. Implementing classes should use their underlying transport to broadcast the message across the cluster.

Parameters:
message - The notification message to broadcast.

OSCache Project Page