com.opensymphony.oscache.plugins.clustersupport
Class JavaGroupsBroadcastingListener

java.lang.Object
  extended by com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
      extended by com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener
All Implemented Interfaces:
CacheEntryEventListener, CacheEventListener, LifecycleAware, EventListener, org.jgroups.blocks.NotificationBus.Consumer

public class JavaGroupsBroadcastingListener
extends AbstractBroadcastingListener
implements org.jgroups.blocks.NotificationBus.Consumer

A concrete implementation of the AbstractBroadcastingListener based on the JavaGroups library. This Class uses JavaGroups to broadcast cache flush messages across a cluster.

One of the following properties should be configured in oscache.properties for this listener:

Please refer to the clustering documentation for further details on the configuration of this listener.

Author:
Chris Miller

Field Summary
 
Fields inherited from class com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
cache, CLUSTER_ORIGIN
 
Constructor Summary
JavaGroupsBroadcastingListener()
           
 
Method Summary
 void finialize()
          Shuts down the JavaGroups being managed by this listener.
 Serializable getCache()
          We are not using the caching, so we just return something that identifies us.
 void handleNotification(Serializable serializable)
          Handles incoming notification messages from JavaGroups.
 void initialize(Cache cache, Config config)
          Initializes the broadcasting listener by starting up a JavaGroups notification bus instance to handle incoming and outgoing messages.
 void memberJoined(org.jgroups.Address address)
          A callback that is fired when a new member joins the cluster.
 void memberLeft(org.jgroups.Address address)
          A callback that is fired when an existing member leaves the cluster.
protected  void sendNotification(ClusterNotification message)
          Uses JavaGroups to broadcast the supplied notification message across the cluster.
 
Methods inherited from class com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
cacheEntryAdded, cacheEntryFlushed, cacheEntryRemoved, cacheEntryUpdated, cacheFlushed, cacheGroupAdded, cacheGroupEntryAdded, cacheGroupEntryRemoved, cacheGroupFlushed, cacheGroupRemoved, cacheGroupUpdated, cachePatternFlushed, handleClusterNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaGroupsBroadcastingListener

public JavaGroupsBroadcastingListener()
Method Detail

initialize

public void initialize(Cache cache,
                       Config config)
                throws InitializationException
Initializes the broadcasting listener by starting up a JavaGroups notification bus instance to handle incoming and outgoing messages.

Specified by:
initialize in interface LifecycleAware
Overrides:
initialize in class AbstractBroadcastingListener
Parameters:
config - An OSCache configuration object.
cache - the cache instance that this listener is attached to.
Throws:
InitializationException - If this listener has already been initialized.

finialize

public void finialize()
               throws FinalizationException
Shuts down the JavaGroups being managed by this listener. This occurs once the cache is shut down and this listener is no longer in use.

Specified by:
finialize in interface LifecycleAware
Throws:
FinalizationException

sendNotification

protected void sendNotification(ClusterNotification message)
Uses JavaGroups to broadcast the supplied notification message across the cluster.

Specified by:
sendNotification in class AbstractBroadcastingListener
Parameters:
message - The cluster nofication message to broadcast.

handleNotification

public void handleNotification(Serializable serializable)
Handles incoming notification messages from JavaGroups. This method should never be called directly.

Specified by:
handleNotification in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
serializable - The incoming message object. This must be a ClusterNotification.

getCache

public Serializable getCache()
We are not using the caching, so we just return something that identifies us. This method should never be called directly.

Specified by:
getCache in interface org.jgroups.blocks.NotificationBus.Consumer

memberJoined

public void memberJoined(org.jgroups.Address address)
A callback that is fired when a new member joins the cluster. This method should never be called directly.

Specified by:
memberJoined in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
address - The address of the member who just joined.

memberLeft

public void memberLeft(org.jgroups.Address address)
A callback that is fired when an existing member leaves the cluster. This method should never be called directly.

Specified by:
memberLeft in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
address - The address of the member who left.

OSCache Project Page