001
014
015 package com.liferay.portal.cache.ehcache;
016
017 import com.liferay.portal.kernel.cache.AggregatedCacheListener;
018
019 import java.io.Serializable;
020
021 import java.util.Collection;
022
023 import net.sf.ehcache.Ehcache;
024 import net.sf.ehcache.Element;
025 import net.sf.ehcache.constructs.EhcacheDecoratorAdapter;
026
027
030 public class LiferayCacheDecorator extends EhcacheDecoratorAdapter {
031
032 public LiferayCacheDecorator(Ehcache underlyingCache) {
033 super(underlyingCache);
034 }
035
036 @Override
037 public boolean equals(Object object) {
038 return underlyingCache.equals(object);
039 }
040
041 public Ehcache getUnderlyingCache() {
042 return underlyingCache;
043 }
044
045 @Override
046 public int hashCode() {
047 return underlyingCache.hashCode();
048 }
049
050 @Override
051 public void put(Element element, boolean doNotNotifyCacheReplicators) {
052 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
053
054 AggregatedCacheListener.setRemoteInvoke(doNotNotifyCacheReplicators);
055
056 try {
057 super.put(element, doNotNotifyCacheReplicators);
058 }
059 finally {
060 AggregatedCacheListener.setRemoteInvoke(remoteInvoke);
061 }
062 }
063
064 @Override
065 public Element putIfAbsent(
066 Element element, boolean doNotNotifyCacheReplicators) {
067
068 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
069
070 AggregatedCacheListener.setRemoteInvoke(doNotNotifyCacheReplicators);
071
072 try {
073 return super.putIfAbsent(element, doNotNotifyCacheReplicators);
074 }
075 finally {
076 AggregatedCacheListener.setRemoteInvoke(remoteInvoke);
077 }
078 }
079
080 @Override
081 public boolean remove(Object key, boolean doNotNotifyCacheReplicators) {
082 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
083
084 AggregatedCacheListener.setRemoteInvoke(doNotNotifyCacheReplicators);
085
086 try {
087 return super.remove(key, doNotNotifyCacheReplicators);
088 }
089 finally {
090 AggregatedCacheListener.setRemoteInvoke(remoteInvoke);
091 }
092 }
093
094 @Override
095 public boolean remove(
096 Serializable key, boolean doNotNotifyCacheReplicators) {
097
098 return remove((Object)key, doNotNotifyCacheReplicators);
099 }
100
101 @Override
102 public void removeAll(boolean doNotNotifyCacheReplicators) {
103 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
104
105 AggregatedCacheListener.setRemoteInvoke(doNotNotifyCacheReplicators);
106
107 try {
108 super.removeAll(doNotNotifyCacheReplicators);
109 }
110 finally {
111 AggregatedCacheListener.setRemoteInvoke(remoteInvoke);
112 }
113 }
114
115 @Override
116 public void removeAll(
117 Collection<?> keys, boolean doNotNotifyCacheReplicators) {
118
119 boolean remoteInvoke = AggregatedCacheListener.isRemoteInvoke();
120
121 AggregatedCacheListener.setRemoteInvoke(doNotNotifyCacheReplicators);
122
123 try {
124 super.removeAll(keys, doNotNotifyCacheReplicators);
125 }
126 finally {
127 AggregatedCacheListener.setRemoteInvoke(remoteInvoke);
128 }
129 }
130
131 }