FileDocCategorySizeDatePackage
ClusterSyncEntityInstanceCache.javaAPI DocJBoss 4.2.14066Fri Jul 13 20:52:34 BST 2007org.jboss.ejb.plugins

ClusterSyncEntityInstanceCache

public class ClusterSyncEntityInstanceCache extends EntityInstanceCache implements org.jboss.ha.framework.interfaces.DistributedState.DSListenerEx
Cache subclass for entity beans shared accross a cluster with distributed cache corruption mechanism.
author
Sacha Labourey
version
$Revision: 57188 $

Fields Summary
protected org.jboss.ha.framework.interfaces.DistributedState
ds
protected String
DS_CATEGORY
Constructors Summary
Methods Summary
public voidcacheMiss(java.lang.String key)

      // a modification has occured on another node, we clean the cache!

      try
      {
         this.remove(key);
      }
      catch (Exception e)
      {
         log.warn("failed to remove key" ,e);
      }
   
public voidcreate()


       
   
      super.create ();

      // Get a reference to the DS service
      ClusterConfigMetaData config = getContainer().getBeanMetaData().getClusterConfigMetaData();
      String partitionName = config.getPartitionName();
      String name = "jboss:service=DistributedState,partitionName=" + partitionName;
      ds = (DistributedState) Registry.lookup (name);
      if( ds == null )
         throw new DeploymentException("Failed to find DistributedState service: "+name);
   
public voidkeyHasBeenRemoved(java.lang.String category, java.io.Serializable key, java.io.Serializable previousContent, boolean locallyModified)
Called whenever a key has been removed from a category the called object had subscribed in.

param
category The category under which a key has been removed
param
key The key that has been removed
param
previousContent The previous content of the key that has been removed

      if (!locallyModified)
         this.cacheMiss ((String)key);
   
public voidstart()

      super.start ();

      String ejbName = this.getContainer ().getBeanMetaData ().getEjbName ();
      this.DS_CATEGORY = "CMPClusteredInMemoryPersistenceManager-" + ejbName;

      this.ds.registerDSListenerEx (this.DS_CATEGORY, this);
   
public voidstop()

      super.stop ();
      this.ds.unregisterDSListenerEx (this.DS_CATEGORY, this);
   
public voidvalueHasChanged(java.lang.String category, java.io.Serializable key, java.io.Serializable value, boolean locallyModified)
Called whenever a key has been added or modified in the category the called object has subscribed in.

param
category The category of the modified/added entry
param
key The key that has been added or its value modified
param
value The new value of the key

      if (!locallyModified)
         this.cacheMiss ((String)key);