01: package org.shiftone.cache.decorator.cluster;
02:
03: import org.jgroups.blocks.NotificationBus;
04: import org.shiftone.cache.util.Log;
05:
06: /**
07: * @version $Revision: 1.2 $
08: * @author $Author: jeffdrost $
09: */
10: public class ClusterBus {
11:
12: private static final Log LOG = new Log(ClusterBus.class);
13: private final ClusterCacheFactory clusterCacheFactory;
14: private NotificationBus bus;
15: private boolean aloneInCluster = true;
16:
17: public ClusterBus(ClusterCacheFactory clusterCacheFactory)
18: throws Exception {
19:
20: this .clusterCacheFactory = clusterCacheFactory;
21: this .bus = new NotificationBus(
22: clusterCacheFactory.getBusName(), clusterCacheFactory
23: .getChannelProperties());
24:
25: bus.setConsumer(new ClusterConsumer(this ));
26: bus.start();
27: }
28:
29: public void sendNotification(Notification notification) {
30:
31: if (isAloneInCluster() == false) {
32: bus.sendNotification(notification);
33: }
34: }
35:
36: public boolean isAloneInCluster() {
37: return aloneInCluster;
38: }
39:
40: public void setAloneInCluster(boolean aloneInCluster) {
41: this .aloneInCluster = aloneInCluster;
42: }
43:
44: public ClusterCacheFactory getClusterCacheFactory() {
45: return clusterCacheFactory;
46: }
47: }
|