001
014
015 package com.liferay.portal.cache.cluster;
016
017 import com.liferay.portal.kernel.cache.cluster.PortalCacheClusterEvent;
018 import com.liferay.portal.kernel.cache.cluster.PortalCacheClusterEventType;
019 import com.liferay.portal.kernel.cache.cluster.PortalCacheClusterLinkUtil;
020 import com.liferay.portal.kernel.util.StringPool;
021
022 import net.sf.ehcache.CacheException;
023 import net.sf.ehcache.Ehcache;
024 import net.sf.ehcache.Element;
025 import net.sf.ehcache.distribution.CacheReplicator;
026
027
030 public class EhcachePortalCacheClusterReplicator implements CacheReplicator {
031
032 public boolean alive() {
033 return true;
034 }
035
036 @Override
037 public Object clone() throws CloneNotSupportedException {
038 return super.clone();
039 }
040
041 public void dispose() {
042 }
043
044 public boolean isReplicateUpdatesViaCopy() {
045 return false;
046 }
047
048 public boolean notAlive() {
049 return false;
050 }
051
052 public void notifyElementEvicted(Ehcache ehcache, Element element) {
053 }
054
055 public void notifyElementExpired(Ehcache ehcache, Element element) {
056 }
057
058 public void notifyElementPut(Ehcache ehcache, Element element)
059 throws CacheException {
060 }
061
062 public void notifyElementRemoved(Ehcache ehcache, Element element)
063 throws CacheException {
064
065 PortalCacheClusterEvent portalCacheClusterEvent =
066 new PortalCacheClusterEvent(
067 ehcache.getName(), element.getKey(),
068 PortalCacheClusterEventType.REMOVE);
069
070 PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
071 }
072
073 public void notifyElementUpdated(Ehcache ehcache, Element element)
074 throws CacheException {
075
076 PortalCacheClusterEvent portalCacheClusterEvent =
077 new PortalCacheClusterEvent(
078 ehcache.getName(), element.getKey(),
079 PortalCacheClusterEventType.UPDATE);
080
081 PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
082 }
083
084 public void notifyRemoveAll(Ehcache ehcache) {
085 PortalCacheClusterEvent portalCacheClusterEvent =
086 new PortalCacheClusterEvent(
087 ehcache.getName(), StringPool.BLANK,
088 PortalCacheClusterEventType.REMOVEALL);
089
090 PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
091 }
092
093 }