1 package org.shiftone.cache.decorator.cluster; 2 3 4 5 import org.jgroups.blocks.NotificationBus; 6 import org.shiftone.cache.util.Log; 7 8 9 13 public class ClusterBus 14 { 15 16 private static final Log LOG = new Log(ClusterBus.class); 17 private final ClusterCacheFactory clusterCacheFactory; 18 private NotificationBus bus; 19 private boolean aloneInCluster = true; 20 21 public ClusterBus(ClusterCacheFactory clusterCacheFactory) throws Exception 22 { 23 24 this.clusterCacheFactory = clusterCacheFactory; 25 this.bus = new NotificationBus(clusterCacheFactory.getBusName(), clusterCacheFactory.getChannelProperties()); 26 27 bus.setConsumer(new ClusterConsumer(this)); 28 bus.start(); 29 } 30 31 32 public void sendNotification(Notification notification) 33 { 34 35 if (isAloneInCluster() == false) 36 { 37 bus.sendNotification(notification); 38 } 39 } 40 41 42 public boolean isAloneInCluster() 43 { 44 return aloneInCluster; 45 } 46 47 48 public void setAloneInCluster(boolean aloneInCluster) 49 { 50 this.aloneInCluster = aloneInCluster; 51 } 52 53 54 public ClusterCacheFactory getClusterCacheFactory() 55 { 56 return clusterCacheFactory; 57 } 58 } 59 | Popular Tags |