Package org.shiftone.cache.decorator.cluster

Source Code of org.shiftone.cache.decorator.cluster.ClusterBus

package org.shiftone.cache.decorator.cluster;



import org.jgroups.blocks.NotificationBus;
import org.shiftone.cache.util.Log;


/**
* @version $Revision: 1.2 $
* @author $Author: jeffdrost $
*/
public class ClusterBus
{

    private static final Log          LOG = new Log(ClusterBus.class);
    private final ClusterCacheFactory clusterCacheFactory;
    private NotificationBus           bus;
    private boolean                   aloneInCluster = true;

    public ClusterBus(ClusterCacheFactory clusterCacheFactory) throws Exception
    {

        this.clusterCacheFactory = clusterCacheFactory;
        this.bus                 = new NotificationBus(clusterCacheFactory.getBusName(), clusterCacheFactory.getChannelProperties());

        bus.setConsumer(new ClusterConsumer(this));
        bus.start();
    }


    public void sendNotification(Notification notification)
    {

        if (isAloneInCluster() == false)
        {
            bus.sendNotification(notification);
        }
    }


    public boolean isAloneInCluster()
    {
        return aloneInCluster;
    }


    public void setAloneInCluster(boolean aloneInCluster)
    {
        this.aloneInCluster = aloneInCluster;
    }


    public ClusterCacheFactory getClusterCacheFactory()
    {
        return clusterCacheFactory;
    }
}
TOP

Related Classes of org.shiftone.cache.decorator.cluster.ClusterBus

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.