001
014
015 package com.liferay.portal.cache.ehcache;
016
017 import java.beans.PropertyChangeListener;
018
019 import java.io.Serializable;
020
021 import java.util.Collection;
022 import java.util.List;
023 import java.util.Map;
024 import java.util.concurrent.atomic.AtomicInteger;
025
026 import net.sf.ehcache.CacheException;
027 import net.sf.ehcache.CacheManager;
028 import net.sf.ehcache.Ehcache;
029 import net.sf.ehcache.Element;
030 import net.sf.ehcache.Statistics;
031 import net.sf.ehcache.Status;
032 import net.sf.ehcache.bootstrap.BootstrapCacheLoader;
033 import net.sf.ehcache.config.CacheConfiguration;
034 import net.sf.ehcache.event.RegisteredEventListeners;
035 import net.sf.ehcache.exceptionhandler.CacheExceptionHandler;
036 import net.sf.ehcache.extension.CacheExtension;
037 import net.sf.ehcache.loader.CacheLoader;
038 import net.sf.ehcache.search.Attribute;
039 import net.sf.ehcache.search.Query;
040 import net.sf.ehcache.statistics.CacheUsageListener;
041 import net.sf.ehcache.statistics.LiveCacheStatistics;
042 import net.sf.ehcache.statistics.sampled.SampledCacheStatistics;
043 import net.sf.ehcache.terracotta.TerracottaNotRunningException;
044 import net.sf.ehcache.transaction.manager.TransactionManagerLookup;
045 import net.sf.ehcache.writer.CacheWriter;
046 import net.sf.ehcache.writer.CacheWriterManager;
047
048
051 public class ModifiableEhcacheWrapper implements Ehcache {
052
053 public ModifiableEhcacheWrapper(Ehcache ehcache) {
054 _ehcache = ehcache;
055 }
056
057 public void acquireReadLockOnKey(Object key) {
058 _ehcache.acquireReadLockOnKey(key);
059 }
060
061 public void acquireWriteLockOnKey(Object key) {
062 _ehcache.acquireWriteLockOnKey(key);
063 }
064
065 public void addPropertyChangeListener(
066 PropertyChangeListener propertyChangeListener) {
067
068 _ehcache.addPropertyChangeListener(propertyChangeListener);
069 }
070
071 public void addReference() {
072 _referenceCounter.incrementAndGet();
073 }
074
075 public void bootstrap() {
076 _ehcache.bootstrap();
077 }
078
079 public long calculateInMemorySize()
080 throws CacheException, IllegalStateException {
081
082 return _ehcache.calculateInMemorySize();
083 }
084
085 public long calculateOffHeapSize()
086 throws CacheException, IllegalStateException {
087
088 return _ehcache.calculateOffHeapSize();
089 }
090
091 public void clearStatistics() {
092 _ehcache.clearStatistics();
093 }
094
095 @Override
096 public Object clone() throws CloneNotSupportedException {
097 return _ehcache.clone();
098 }
099
100 public Query createQuery() {
101 return _ehcache.createQuery();
102 }
103
104 public void disableDynamicFeatures() {
105 _ehcache.disableDynamicFeatures();
106 }
107
108 public void dispose() throws IllegalStateException {
109 _ehcache.dispose();
110 }
111
112 @Override
113 public boolean equals(Object object) {
114 return _ehcache.equals(object);
115 }
116
117 public void evictExpiredElements() {
118 _ehcache.evictExpiredElements();
119 }
120
121 public void flush() throws CacheException, IllegalStateException {
122 _ehcache.flush();
123 }
124
125 public Element get(Object key)
126 throws CacheException, IllegalStateException {
127
128 return _ehcache.get(key);
129 }
130
131 public Element get(Serializable key)
132 throws CacheException, IllegalStateException {
133
134 return _ehcache.get(key);
135 }
136
137 public int getActiveReferenceCount() {
138 return _referenceCounter.get();
139 }
140
141 @SuppressWarnings("rawtypes")
142 public Map getAllWithLoader(Collection keys, Object argument)
143 throws CacheException {
144
145 return _ehcache.getAllWithLoader(keys, argument);
146 }
147
148 public float getAverageGetTime() {
149 return _ehcache.getAverageGetTime();
150 }
151
152 public long getAverageSearchTime() {
153 return _ehcache.getAverageSearchTime();
154 }
155
156 public BootstrapCacheLoader getBootstrapCacheLoader() {
157 return _ehcache.getBootstrapCacheLoader();
158 }
159
160 public CacheConfiguration getCacheConfiguration() {
161 return _ehcache.getCacheConfiguration();
162 }
163
164 public RegisteredEventListeners getCacheEventNotificationService() {
165 return _ehcache.getCacheEventNotificationService();
166 }
167
168 public CacheExceptionHandler getCacheExceptionHandler() {
169 return _ehcache.getCacheExceptionHandler();
170 }
171
172 public CacheManager getCacheManager() {
173 return _ehcache.getCacheManager();
174 }
175
176 public int getDiskStoreSize() throws IllegalStateException {
177 return _ehcache.getDiskStoreSize();
178 }
179
180 public String getGuid() {
181 return _ehcache.getGuid();
182 }
183
184 public Object getInternalContext() {
185 return _ehcache.getInternalContext();
186 }
187
188 @SuppressWarnings("rawtypes")
189 public List getKeys() throws CacheException, IllegalStateException {
190 return _ehcache.getKeys();
191 }
192
193 @SuppressWarnings("rawtypes")
194 public List getKeysNoDuplicateCheck() throws IllegalStateException {
195 return _ehcache.getKeysNoDuplicateCheck();
196 }
197
198 @SuppressWarnings("rawtypes")
199 public List getKeysWithExpiryCheck()
200 throws CacheException, IllegalStateException {
201
202 return _ehcache.getKeysWithExpiryCheck();
203 }
204
205 public LiveCacheStatistics getLiveCacheStatistics()
206 throws IllegalStateException {
207
208 return _ehcache.getLiveCacheStatistics();
209 }
210
211 public long getMemoryStoreSize() throws IllegalStateException {
212 return _ehcache.getMemoryStoreSize();
213 }
214
215 public String getName() {
216 return _ehcache.getName();
217 }
218
219 public long getOffHeapStoreSize() throws IllegalStateException {
220 return _ehcache.getOffHeapStoreSize();
221 }
222
223 public Element getQuiet(Object key)
224 throws CacheException, IllegalStateException {
225
226 return _ehcache.getQuiet(key);
227 }
228
229 public Element getQuiet(Serializable key)
230 throws CacheException, IllegalStateException {
231
232 return _ehcache.getQuiet(key);
233 }
234
235 public List<CacheExtension> getRegisteredCacheExtensions() {
236 return _ehcache.getRegisteredCacheExtensions();
237 }
238
239 public List<CacheLoader> getRegisteredCacheLoaders() {
240 return _ehcache.getRegisteredCacheLoaders();
241 }
242
243 public CacheWriter getRegisteredCacheWriter() {
244 return _ehcache.getRegisteredCacheWriter();
245 }
246
247 public SampledCacheStatistics getSampledCacheStatistics() {
248 return _ehcache.getSampledCacheStatistics();
249 }
250
251 public <T> Attribute<T> getSearchAttribute(String attributeName)
252 throws CacheException {
253
254 return _ehcache.getSearchAttribute(attributeName);
255 }
256
257 public long getSearchesPerSecond() {
258 return _ehcache.getSearchesPerSecond();
259 }
260
261 public int getSize() throws CacheException, IllegalStateException {
262 return _ehcache.getSize();
263 }
264
265 public int getSizeBasedOnAccuracy(int statisticsAccuracy)
266 throws CacheException, IllegalArgumentException, IllegalStateException {
267
268 return _ehcache.getSizeBasedOnAccuracy(statisticsAccuracy);
269 }
270
271 public Statistics getStatistics() throws IllegalStateException {
272 return _ehcache.getStatistics();
273 }
274
275 public int getStatisticsAccuracy() {
276 return _ehcache.getStatisticsAccuracy();
277 }
278
279 public Status getStatus() {
280 return _ehcache.getStatus();
281 }
282
283 public Element getWithLoader(
284 Object key, CacheLoader cacheLoader, Object argument)
285 throws CacheException {
286
287 return _ehcache.getWithLoader(key, cacheLoader, argument);
288 }
289
290 public Ehcache getWrappedCache() {
291 return _ehcache;
292 }
293
294 public CacheWriterManager getWriterManager() {
295 return _ehcache.getWriterManager();
296 }
297
298 @Override
299 public int hashCode() {
300 return _ehcache.hashCode();
301 }
302
303 public void initialise() {
304 _ehcache.initialise();
305 }
306
307 public boolean isClusterBulkLoadEnabled()
308 throws TerracottaNotRunningException, UnsupportedOperationException {
309
310 return _ehcache.isClusterBulkLoadEnabled();
311 }
312
313
316 public boolean isClusterCoherent() {
317 return _ehcache.isClusterCoherent();
318 }
319
320 public boolean isDisabled() {
321 return _ehcache.isDisabled();
322 }
323
324 public boolean isElementInMemory(Object key) {
325 return _ehcache.isElementInMemory(key);
326 }
327
328 public boolean isElementInMemory(Serializable key) {
329 return _ehcache.isElementInMemory(key);
330 }
331
332 public boolean isElementOnDisk(Object key) {
333 return _ehcache.isElementOnDisk(key);
334 }
335
336 public boolean isElementOnDisk(Serializable key) {
337 return _ehcache.isElementOnDisk(key);
338 }
339
340 public boolean isExpired(Element element)
341 throws IllegalStateException, NullPointerException {
342
343 return _ehcache.isExpired(element);
344 }
345
346 public boolean isKeyInCache(Object key) {
347 return _ehcache.isKeyInCache(key);
348 }
349
350 public boolean isNodeBulkLoadEnabled()
351 throws TerracottaNotRunningException, UnsupportedOperationException {
352
353 return _ehcache.isNodeBulkLoadEnabled();
354 }
355
356
359 public boolean isNodeCoherent() {
360 return _ehcache.isNodeCoherent();
361 }
362
363 public boolean isReadLockedByCurrentThread(Object key) {
364 return _ehcache.isReadLockedByCurrentThread(key);
365 }
366
367 public boolean isSampledStatisticsEnabled() {
368 return _ehcache.isSampledStatisticsEnabled();
369 }
370
371 public boolean isSearchable() {
372 return _ehcache.isSearchable();
373 }
374
375 public boolean isStatisticsEnabled() {
376 return _ehcache.isStatisticsEnabled();
377 }
378
379 public boolean isValueInCache(Object value) {
380 return _ehcache.isValueInCache(value);
381 }
382
383 public boolean isWriteLockedByCurrentThread(Object key) {
384 return _ehcache.isWriteLockedByCurrentThread(key);
385 }
386
387 public void load(Object key) throws CacheException {
388 _ehcache.load(key);
389 }
390
391 @SuppressWarnings("rawtypes")
392 public void loadAll(Collection keys, Object argument)
393 throws CacheException {
394
395 _ehcache.loadAll(keys, argument);
396 }
397
398 public void put(Element element)
399 throws CacheException, IllegalArgumentException, IllegalStateException {
400
401 _ehcache.put(element);
402 }
403
404 public void put(Element element, boolean doNotNotifyCacheReplicators)
405 throws CacheException, IllegalArgumentException, IllegalStateException {
406
407 _ehcache.put(element, doNotNotifyCacheReplicators);
408 }
409
410 public Element putIfAbsent(Element element) throws NullPointerException {
411 return _ehcache.putIfAbsent(element);
412 }
413
414 public void putQuiet(Element element)
415 throws CacheException, IllegalArgumentException, IllegalStateException {
416
417 _ehcache.putQuiet(element);
418 }
419
420 public void putWithWriter(Element element)
421 throws CacheException, IllegalArgumentException, IllegalStateException {
422
423 _ehcache.putWithWriter(element);
424 }
425
426 public void registerCacheExtension(CacheExtension cacheExtension) {
427 _ehcache.registerCacheExtension(cacheExtension);
428 }
429
430 public void registerCacheLoader(CacheLoader cacheLoader) {
431 _ehcache.registerCacheLoader(cacheLoader);
432 }
433
434 public void registerCacheUsageListener(
435 CacheUsageListener cacheUsageListener)
436 throws IllegalStateException {
437
438 _ehcache.registerCacheUsageListener(cacheUsageListener);
439 }
440
441 public void registerCacheWriter(CacheWriter cacheWriter) {
442 _ehcache.registerCacheWriter(cacheWriter);
443 }
444
445 public void releaseReadLockOnKey(Object key) {
446 _ehcache.releaseReadLockOnKey(key);
447 }
448
449 public void releaseWriteLockOnKey(Object key) {
450 _ehcache.releaseWriteLockOnKey(key);
451 }
452
453 public boolean remove(Object key) throws IllegalStateException {
454 return _ehcache.remove(key);
455 }
456
457 public boolean remove(Object key, boolean doNotNotifyCacheReplicators)
458 throws IllegalStateException {
459
460 return _ehcache.remove(key, doNotNotifyCacheReplicators);
461 }
462
463 public boolean remove(Serializable key) throws IllegalStateException {
464 return _ehcache.remove(key);
465 }
466
467 public boolean remove(Serializable key, boolean doNotNotifyCacheReplicators)
468 throws IllegalStateException {
469
470 return _ehcache.remove(key, doNotNotifyCacheReplicators);
471 }
472
473 public void removeAll() throws CacheException, IllegalStateException {
474 _ehcache.removeAll();
475 }
476
477 public void removeAll(boolean doNotNotifyCacheReplicators)
478 throws CacheException, IllegalStateException {
479
480 _ehcache.removeAll(doNotNotifyCacheReplicators);
481 }
482
483 public void removeCacheUsageListener(CacheUsageListener cacheUsageListener)
484 throws IllegalStateException {
485
486 _ehcache.removeCacheUsageListener(cacheUsageListener);
487 }
488
489 public boolean removeElement(Element element) throws NullPointerException {
490 return _ehcache.removeElement(element);
491 }
492
493 public void removePropertyChangeListener(
494 PropertyChangeListener propertyChangeListener) {
495
496 _ehcache.removePropertyChangeListener(propertyChangeListener);
497 }
498
499 public boolean removeQuiet(Object key) throws IllegalStateException {
500 return _ehcache.removeQuiet(key);
501 }
502
503 public boolean removeQuiet(Serializable key) throws IllegalStateException {
504 return _ehcache.removeQuiet(key);
505 }
506
507 public void removeReference() {
508 _referenceCounter.decrementAndGet();
509 }
510
511 public boolean removeWithWriter(Object key)
512 throws CacheException, IllegalStateException {
513
514 return _ehcache.removeWithWriter(key);
515 }
516
517 public Element replace(Element element) throws NullPointerException {
518 return _ehcache.replace(element);
519 }
520
521 public boolean replace(Element oldElement, Element newElement)
522 throws IllegalArgumentException, NullPointerException {
523
524 return _ehcache.replace(oldElement, newElement);
525 }
526 public void setBootstrapCacheLoader(
527 BootstrapCacheLoader bootstrapCacheLoader)
528 throws CacheException {
529
530 _ehcache.setBootstrapCacheLoader(bootstrapCacheLoader);
531 }
532
533 public void setCacheExceptionHandler(
534 CacheExceptionHandler cacheExceptionHandler) {
535
536 _ehcache.setCacheExceptionHandler(cacheExceptionHandler);
537 }
538
539 public void setCacheManager(CacheManager cacheManager) {
540 _ehcache.setCacheManager(cacheManager);
541 }
542
543 public void setDisabled(boolean disabled) {
544 _ehcache.setDisabled(disabled);
545 }
546
547 public void setDiskStorePath(String diskStorePath) throws CacheException {
548 _ehcache.setDiskStorePath(diskStorePath);
549 }
550
551 public void setName(String name) {
552 _ehcache.setName(name);
553 }
554
555 public void setNodeBulkLoadEnabled(boolean enabledBulkLoad)
556 throws TerracottaNotRunningException, UnsupportedOperationException {
557
558 _ehcache.setNodeBulkLoadEnabled(enabledBulkLoad);
559 }
560
561
564 public void setNodeCoherent(boolean nodeCoherent)
565 throws UnsupportedOperationException {
566
567 _ehcache.setNodeCoherent(nodeCoherent);
568 }
569
570 public void setSampledStatisticsEnabled(boolean sampleStatisticsEnabled) {
571 _ehcache.setSampledStatisticsEnabled(sampleStatisticsEnabled);
572 }
573
574 public void setStatisticsAccuracy(int statisticsAccuracy) {
575 _ehcache.setStatisticsAccuracy(statisticsAccuracy);
576 }
577
578 public void setStatisticsEnabled(boolean statisticsEnabled) {
579 _ehcache.setStatisticsEnabled(statisticsEnabled);
580 }
581
582 public void setTransactionManagerLookup(
583 TransactionManagerLookup transactionManagerLookup) {
584
585 _ehcache.setTransactionManagerLookup(transactionManagerLookup);
586 }
587
588 public void setWrappedCache(Ehcache ehcache) {
589 _ehcache = ehcache;
590 }
591
592 public boolean tryReadLockOnKey(Object key, long timeout)
593 throws InterruptedException {
594
595 return _ehcache.tryReadLockOnKey(key, timeout);
596 }
597
598 public boolean tryWriteLockOnKey(Object key, long timeout)
599 throws InterruptedException {
600
601 return _ehcache.tryWriteLockOnKey(key, timeout);
602 }
603
604 public void unregisterCacheExtension(CacheExtension cacheExtension) {
605 _ehcache.unregisterCacheExtension(cacheExtension);
606 }
607
608 public void unregisterCacheLoader(CacheLoader cacheLoader) {
609 _ehcache.unregisterCacheLoader(cacheLoader);
610 }
611
612 public void unregisterCacheWriter() {
613 _ehcache.unregisterCacheWriter();
614 }
615
616 public void waitUntilClusterBulkLoadComplete()
617 throws TerracottaNotRunningException, UnsupportedOperationException {
618
619 _ehcache.waitUntilClusterBulkLoadComplete();
620 }
621
622
625 public void waitUntilClusterCoherent()
626 throws UnsupportedOperationException {
627
628 _ehcache.waitUntilClusterCoherent();
629 }
630
631 private Ehcache _ehcache;
632 private AtomicInteger _referenceCounter = new AtomicInteger(0);
633
634 }