1 22 package org.jboss.ejb.plugins; 23 24 import org.jboss.deployment.DeploymentException; 25 import org.jboss.ha.framework.interfaces.DistributedState; 26 import org.jboss.metadata.ClusterConfigMetaData; 27 import org.jboss.system.Registry; 28 29 36 public class ClusterSyncEntityInstanceCache 37 extends EntityInstanceCache 38 implements org.jboss.ha.framework.interfaces.DistributedState.DSListenerEx 39 { 40 protected DistributedState ds = null; 41 protected String DS_CATEGORY = null; 42 43 public void create() throws Exception 44 { 45 super.create (); 46 47 ClusterConfigMetaData config = getContainer().getBeanMetaData().getClusterConfigMetaData(); 49 String partitionName = config.getPartitionName(); 50 String name = "jboss:service=DistributedState,partitionName=" + partitionName; 51 ds = (DistributedState) Registry.lookup (name); 52 if( ds == null ) 53 throw new DeploymentException("Failed to find DistributedState service: "+name); 54 } 55 56 public void start() throws Exception 57 { 58 super.start (); 59 60 String ejbName = this.getContainer ().getBeanMetaData ().getEjbName (); 61 this.DS_CATEGORY = "CMPClusteredInMemoryPersistenceManager-" + ejbName; 62 63 this.ds.registerDSListenerEx (this.DS_CATEGORY, this); 64 } 65 66 67 public void stop() 68 { 69 super.stop (); 70 this.ds.unregisterDSListenerEx (this.DS_CATEGORY, this); 71 } 72 73 75 82 public void keyHasBeenRemoved (String category, java.io.Serializable key, java.io.Serializable previousContent, boolean locallyModified) 83 { 84 if (!locallyModified) 85 this.cacheMiss ((String )key); 86 } 87 88 95 public void valueHasChanged (String category, java.io.Serializable key, java.io.Serializable value, boolean locallyModified) 96 { 97 if (!locallyModified) 98 this.cacheMiss ((String )key); 99 } 100 101 public void cacheMiss(String key) 102 { 103 105 try 106 { 107 this.remove(key); 108 } 109 catch (Exception e) 110 { 111 log.warn("failed to remove key" ,e); 112 } 113 } 114 115 } 116 117 | Popular Tags |