Top Description Fields Constructors Methods
net.sf.ehcache.constructs

public Class EhcacheDecoratorAdapter

extends Object
implements InternalEhcache
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.terracotta.InternalEhcache, net.sf.ehcache.Ehcache, java.lang.Cloneable
Known Direct Subclasses
net.sf.ehcache.constructs.blocking.BlockingCache, net.sf.ehcache.constructs.eventual.StronglyConsistentCacheAccessor, net.sf.ehcache.constructs.readthrough.ReadThroughCache, net.sf.ehcache.constructs.refreshahead.RefreshAheadCache
Imports
java.beans.PropertyChangeListener, java.io.Serializable, java.util.Collection, .List, .Map, .Set, net.sf.ehcache.CacheException, .CacheManager, .Ehcache, .Element, .Status, net.sf.ehcache.bootstrap.BootstrapCacheLoader, net.sf.ehcache.config.CacheConfiguration, net.sf.ehcache.event.RegisteredEventListeners, net.sf.ehcache.exceptionhandler.CacheExceptionHandler, net.sf.ehcache.extension.CacheExtension, net.sf.ehcache.loader.CacheLoader, net.sf.ehcache.search.Attribute, .Query, net.sf.ehcache.search.attribute.DynamicAttributesExtractor, net.sf.ehcache.statistics.StatisticsGateway, net.sf.ehcache.terracotta.InternalEhcache, .TerracottaNotRunningException, net.sf.ehcache.transaction.manager.TransactionManagerLookup, net.sf.ehcache.writer.CacheWriter, .CacheWriterManager, org.terracotta.statistics.StatisticsManager

Adapter class for Ehcache interface decorators. Implements all method in Ehcache by delegating all calls to the decorated Ehcache. This class is provided as a convenience for easily creating Ehcache decorators by extending this class and overriding only the methods of interest.
Author
Abhishek Sanoujam

Field Summary

Modifier and TypeField and Description
protected final Ehcache
underlyingCache

The decorated Ehcache, has protected visibility so that sub-classes can have access to it.

Constructor Summary

AccessConstructor and Description
public
EhcacheDecoratorAdapter(Ehcache underlyingCache)

Constructor accepting the cache to be decorated

Method Summary

Modifier and TypeMethod and Description
public void
acquireReadLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
)

Implements net.sf.ehcache.Ehcache.acquireReadLockOnKey.

Acquires the proper read lock for a given cache key
public void
acquireWriteLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
)

Implements net.sf.ehcache.Ehcache.acquireWriteLockOnKey.

Acquires the proper write lock for a given cache key
public void
addPropertyChangeListener(PropertyChangeListener
the listener to add
listener
)

Implements net.sf.ehcache.Ehcache.addPropertyChangeListener.

Add a PropertyChangeListener.
private InternalEhcache
public void
bootstrap()

Implements net.sf.ehcache.Ehcache.bootstrap.

Bootstrap command.
public long
calculateInMemorySize()

Implements net.sf.ehcache.Ehcache.calculateInMemorySize.

Deprecated
Gets the size of the memory store for this cache

Warning

This method can be very expensive to run.

public long
calculateOffHeapSize()

Implements net.sf.ehcache.Ehcache.calculateOffHeapSize.

Deprecated
Gets the size of the off-heap store for this cache
public long
calculateOnDiskSize()

Implements net.sf.ehcache.Ehcache.calculateOnDiskSize.

Deprecated
Gets the size of the on-disk store for this cache
public Object
clone()

Overrides java.lang.Object.clone.

Implements net.sf.ehcache.Ehcache.clone.

Clones a cache.
public Query
createQuery()

Implements net.sf.ehcache.Ehcache.createQuery.

Create a new query builder for this cache
public void
disableDynamicFeatures()

Implements net.sf.ehcache.Ehcache.disableDynamicFeatures.

Disables dynamic configuration and disable/enable for this cache.
public void
dispose()

Implements net.sf.ehcache.Ehcache.dispose.

Flushes all cache items from memory to auxilliary caches and close the auxilliary caches.
public void
evictExpiredElements()

Implements net.sf.ehcache.Ehcache.evictExpiredElements.

Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted.
public void
flush()

Implements net.sf.ehcache.Ehcache.flush.

Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
public Element
get(Object
an Object value
key
)

Implements net.sf.ehcache.Ehcache.get.

Gets an element from the cache.
public Element
get(Serializable
a serializable value
key
)

Implements net.sf.ehcache.Ehcache.get.

Gets an element from the cache.
public Map<Object, Element>
getAll(Collection<?>
a collection of keys for which value is to be fetched
keys
)

Implements net.sf.ehcache.Ehcache.getAll.

Gets all the elements from the cache for the keys provided.
public Map<K, V>
getAllWithLoader(Collection<E>
a collection of keys to be returned/loaded
keys
,
Object
an argument to pass to the CacheLoader.
loaderArgument
)

Implements net.sf.ehcache.Ehcache.getAllWithLoader.

The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys".
public BootstrapCacheLoader
getBootstrapCacheLoader()

Implements net.sf.ehcache.Ehcache.getBootstrapCacheLoader.

Accessor for the BootstrapCacheLoader associated with this cache.
public CacheConfiguration
getCacheConfiguration()

Implements net.sf.ehcache.Ehcache.getCacheConfiguration.

Gets the cache configuration this cache was created with.
public RegisteredEventListeners
getCacheEventNotificationService()

Implements net.sf.ehcache.Ehcache.getCacheEventNotificationService.

Use this to access the service in order to register and unregister listeners
public CacheExceptionHandler
public CacheManager
getCacheManager()

Implements net.sf.ehcache.Ehcache.getCacheManager.

Gets the CacheManager managing this cache.
public int
getDiskStoreSize()

Implements net.sf.ehcache.Ehcache.getDiskStoreSize.

Deprecated
Returns the number of elements in the disk store.
public String
getGuid()

Implements net.sf.ehcache.Ehcache.getGuid.

The GUID for this cache instance can be used to determine whether two cache instance references are pointing to the same cache.
public Object
public List<E>
getKeys()

Implements net.sf.ehcache.Ehcache.getKeys.

Returns a list of all elements in the cache, whether or not they are expired.
public List<E>
getKeysNoDuplicateCheck()

Implements net.sf.ehcache.Ehcache.getKeysNoDuplicateCheck.

Returns a list of all elements in the cache, whether or not they are expired.
public List<E>
getKeysWithExpiryCheck()

Implements net.sf.ehcache.Ehcache.getKeysWithExpiryCheck.

Returns a list of all elements in the cache.
public long
getMemoryStoreSize()

Implements net.sf.ehcache.Ehcache.getMemoryStoreSize.

Deprecated
Returns the number of elements in the memory store.
public String
getName()

Implements net.sf.ehcache.Ehcache.getName.

Gets the cache name.
public long
getOffHeapStoreSize()

Implements net.sf.ehcache.Ehcache.getOffHeapStoreSize.

Deprecated
Returns the number of elements in the off-heap store.
public Element
getQuiet(Object
a serializable value
key
)

Implements net.sf.ehcache.Ehcache.getQuiet.

Gets an element from the cache, without updating Element statistics.
public Element
getQuiet(Serializable
a serializable value
key
)

Implements net.sf.ehcache.Ehcache.getQuiet.

Gets an element from the cache, without updating Element statistics.
public List<CacheExtension>
public List<CacheLoader>
public CacheWriter
getRegisteredCacheWriter()

Implements net.sf.ehcache.Ehcache.getRegisteredCacheWriter.

Retrieves the CacheWriter that was registered for this cache.
public <T> Attribute<T>
getSearchAttribute(String
the name of the attribute to retrieve
attributeName
)

Implements net.sf.ehcache.Ehcache.getSearchAttribute.

Retrieve the given named search attribute
public Set<Attribute<T>>
public int
getSize()

Implements net.sf.ehcache.Ehcache.getSize.

Gets the size of the cache.
public StatisticsGateway
getStatistics()

Implements net.sf.ehcache.Ehcache.getStatistics.

Gets an immutable Statistics object representing the Cache statistics at the time.
public Status
getStatus()

Implements net.sf.ehcache.Ehcache.getStatus.

Gets the status attribute of the Cache.
public Element
getWithLoader(Object
key whose associated value is to be returned.
key
,
CacheLoader
the override loader to use. If null, the cache's default loader will be used
loader
,
Object
an argument to pass to the CacheLoader.
loaderArgument
)

Implements net.sf.ehcache.Ehcache.getWithLoader.

This method will return, from the cache, the object associated with the argument "key".
public CacheWriterManager
getWriterManager()

Implements net.sf.ehcache.Ehcache.getWriterManager.

Obtain the writer manager that's used by this cache instance.
public boolean
hasAbortedSizeOf()

Implements net.sf.ehcache.Ehcache.hasAbortedSizeOf.

Check if the cache may contain elements which the SizeOf engine could not fully size.
public void
public boolean
isClusterBulkLoadEnabled()

Implements net.sf.ehcache.Ehcache.isClusterBulkLoadEnabled.

Returns true if at least one node in the cluster is in bulk-load mode.
public boolean
isClusterCoherent()

Implements net.sf.ehcache.Ehcache.isClusterCoherent.

Deprecated Use isClusterBulkLoadEnabled() instead
Returns true if the cache is in coherent mode cluster-wide.
public boolean
isDisabled()

Implements net.sf.ehcache.Ehcache.isDisabled.

Whether this cache is disabled.
public boolean
isElementInMemory(Object
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.isElementInMemory.

Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
public boolean
isElementInMemory(Serializable
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.isElementInMemory.

Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
public boolean
isElementOnDisk(Object
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.isElementOnDisk.

Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
public boolean
isElementOnDisk(Serializable
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.isElementOnDisk.

Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
public boolean
isExpired(Element
the element to check
element
)

Implements net.sf.ehcache.Ehcache.isExpired.

Checks whether this cache element has expired.
public boolean
isKeyInCache(Object
the key to check for
key
)

Implements net.sf.ehcache.Ehcache.isKeyInCache.

An inexpensive check to see if the key exists in the cache.
public boolean
isNodeBulkLoadEnabled()

Implements net.sf.ehcache.Ehcache.isNodeBulkLoadEnabled.

Returns true if the current node is in bulk-load mode.
public boolean
isNodeCoherent()

Implements net.sf.ehcache.Ehcache.isNodeCoherent.

Deprecated Use isNodeBulkLoadEnabled() instead
Returns true if the cache is in coherent mode for the current node.
public boolean
isReadLockedByCurrentThread(Object
the key
key
)

Implements net.sf.ehcache.Ehcache.isReadLockedByCurrentThread.

Returns true if a read lock for the key is held by the current thread
public boolean
isSearchable()

Implements net.sf.ehcache.Ehcache.isSearchable.

Is this cache searchable?
public boolean
isValueInCache(Object
to check for
value
)

Implements net.sf.ehcache.Ehcache.isValueInCache.

An extremely expensive check to see if the value exists in the cache.
public boolean
isWriteLockedByCurrentThread(Object
the key
key
)

Implements net.sf.ehcache.Ehcache.isWriteLockedByCurrentThread.

Returns true if a write lock for the key is held by the current thread
public void
load(Object
key whose associated value to be loaded using the associated cacheloader if this cache doesn't contain it.
key
)

Implements net.sf.ehcache.Ehcache.load.

The load method provides a means to "pre load" the cache.
public void
loadAll(Collection<E>
- collection of the keys whose associated values to be loaded into this cache by using the associated cacheloader if this cache doesn't contain them.
keys
,
Object
can be anything that makes sense to the loader

The Ehcache native API provides similar functionality to loaders using the decorator net.sf.ehcache.constructs.blocking.SelfPopulatingCache

argument
)

Implements net.sf.ehcache.Ehcache.loadAll.

The loadAll method provides a means to "pre load" objects into the cache.
public void
put(Element
An object. If Serializable it can fully participate in replication and the DiskStore.
element
,
boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.put.

Put an element in the cache.
public void
put(Element
An object. If Serializable it can fully participate in replication and the DiskStore.
element
)

Implements net.sf.ehcache.Ehcache.put.

Put an element in the cache.
public void
putAll(Collection<Element>
the collection of elements to be put in the cache.
elements
)

Implements net.sf.ehcache.Ehcache.putAll.

Puts a collection of elements in to the cache.
public Element
putIfAbsent(Element
element to be added
element
)

Implements net.sf.ehcache.Ehcache.putIfAbsent.

Put an element in the cache if no element is currently mapped to the elements key.
public Element
putIfAbsent(final Element
element to be added
element
,
final boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.putIfAbsent.

Put an element in the cache if no element is currently mapped to the elements key.
public void
putQuiet(Element
An object. If Serializable it can fully participate in replication and the DiskStore.
element
)

Implements net.sf.ehcache.Ehcache.putQuiet.

Put an element in the cache, without updating statistics, or updating listeners.
public void
putWithWriter(Element
An object. If Serializable it can fully participate in replication and the DiskStore.
element
)

Implements net.sf.ehcache.Ehcache.putWithWriter.

Put an element in the cache writing through a CacheWriter.
public void
recalculateSize(Object
the key
key
)

Implements net.sf.ehcache.terracotta.InternalEhcache.recalculateSize.

Recalculate the size of the element mapped to the key
public void
registerCacheExtension(CacheExtension
the cache extension
cacheExtension
)

Implements net.sf.ehcache.Ehcache.registerCacheExtension.

Register a CacheExtension with the cache.
public void
registerCacheLoader(CacheLoader
A Cache Loader to register
cacheLoader
)

Implements net.sf.ehcache.Ehcache.registerCacheLoader.

Register a CacheLoader with the cache.
public void
registerCacheWriter(CacheWriter
A CacheWriter to register
cacheWriter
)

Implements net.sf.ehcache.Ehcache.registerCacheWriter.

Register the CacheWriter for this cache.
public void
registerDynamicAttributesExtractor(DynamicAttributesExtractor
the dynamic attribute extractor
extractor
)

Implements net.sf.ehcache.Ehcache.registerDynamicAttributesExtractor.

Allows user to register a dynamic attribute extractor with a searchable cache that is dynamically indexable, as indicated by its configuration.
public void
releaseReadLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
)

Implements net.sf.ehcache.Ehcache.releaseReadLockOnKey.

Release a held read lock for the passed in key
public void
releaseWriteLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
)

Implements net.sf.ehcache.Ehcache.releaseWriteLockOnKey.

Release a held write lock for the passed in key
public boolean
remove(Object
of the element to remove
key
,
boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
public boolean
remove(Object
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
public boolean
remove(Serializable
the key of the element to remove
key
,
boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
public boolean
remove(Serializable
the key of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
public void
removeAll(Collection<?>
a collection of keys to operate on
keys
)

Implements net.sf.ehcache.Ehcache.removeAll.

Removes given set of net.sf.ehcache.Element from the Cache.
public void
removeAll(Collection<?>
a collection of keys to operate on
keys
,
boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.removeAll.

Removes all cached items.
public void
removeAll()

Implements net.sf.ehcache.Ehcache.removeAll.

Removes all cached items.
public void
removeAll(boolean
whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
doNotNotifyCacheReplicators
)

Implements net.sf.ehcache.Ehcache.removeAll.

Removes all cached items.
public Element
removeAndReturnElement(Object
the key of the element to operate on
key
)

Implements net.sf.ehcache.terracotta.InternalEhcache.removeAndReturnElement.

Removes and returns the element associated with the key
public boolean
removeElement(Element
Element to be removed
element
)

Implements net.sf.ehcache.Ehcache.removeElement.

Remove the Element mapped to the key for the supplied element if the value of the supplied Element compares equal to the value of the cached Element.
public void
removePropertyChangeListener(PropertyChangeListener
the listener to remove
listener
)

Implements net.sf.ehcache.Ehcache.removePropertyChangeListener.

Remove a PropertyChangeListener.
public boolean
removeQuiet(Object
of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.removeQuiet.

Removes an net.sf.ehcache.Element from the Cache, without notifying listeners.
public boolean
removeQuiet(Serializable
of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.removeQuiet.

Removes an net.sf.ehcache.Element from the Cache, without notifying listeners.
public boolean
removeWithWriter(Object
of the element to remove
key
)

Implements net.sf.ehcache.Ehcache.removeWithWriter.

Removes an net.sf.ehcache.Element from the Cache and any stores it might be in. This also removes through to a CacheWriter.
public boolean
replace(Element
Element to be test against
old
,
Element
Element to be cached
element
)

Implements net.sf.ehcache.Ehcache.replace.

Replace the cached element only if the current Element is equal to the supplied old Element.
public Element
replace(Element
Element to be cached
element
)

Implements net.sf.ehcache.Ehcache.replace.

Replace the cached element only if an Element is currently cached for this key
public void
setBootstrapCacheLoader(BootstrapCacheLoader
the loader to be used
bootstrapCacheLoader
)

Implements net.sf.ehcache.Ehcache.setBootstrapCacheLoader.

Sets the bootstrap cache loader.
public void
setCacheExceptionHandler(CacheExceptionHandler
the cache exception handler
cacheExceptionHandler
)

Implements net.sf.ehcache.Ehcache.setCacheExceptionHandler.

Sets an ExceptionHandler on the Cache.
public void
setCacheManager(CacheManager
the CacheManager for this cache to use.
cacheManager
)

Implements net.sf.ehcache.Ehcache.setCacheManager.

Sets the CacheManager
public void
setDisabled(boolean
true if you wish to disable, false to enable
disabled
)

Implements net.sf.ehcache.Ehcache.setDisabled.

Disables or enables this cache.
public void
setName(String
the name of the cache. Should not be null.
name
)

Implements net.sf.ehcache.Ehcache.setName.

Sets the cache name which will name.
public void
setNodeBulkLoadEnabled(boolean
true enables bulk-load, false disables it if not already disabled
enabledBulkLoad
)

Implements net.sf.ehcache.Ehcache.setNodeBulkLoadEnabled.

Enable/disable bulk-load mode in this node for this cache.
public void
setNodeCoherent(boolean
true transitions to coherent mode, false to incoherent mode
coherent
)

Implements net.sf.ehcache.Ehcache.setNodeCoherent.

Deprecated Use setNodeBulkLoadEnabled(boolean) instead
Sets the cache in coherent or incoherent mode depending on the parameter on this node.
public void
setTransactionManagerLookup(TransactionManagerLookup
the transactionManagerLookup
transactionManagerLookup
)

Implements net.sf.ehcache.Ehcache.setTransactionManagerLookup.

This class is used to access the transaction manager used during XA.
public String
public boolean
tryReadLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
,
long
- millis until giveup on getting the lock
timeout
)

Implements net.sf.ehcache.Ehcache.tryReadLockOnKey.

Try to get a read lock on a given key.
public boolean
tryWriteLockOnKey(Object
- The key that retrieves a value that you want to protect via locking
key
,
long
- millis until giveup on getting the lock
timeout
)

Implements net.sf.ehcache.Ehcache.tryWriteLockOnKey.

Try to get a write lock on a given key.
public void
unregisterCacheExtension(CacheExtension
the cache extension
cacheExtension
)

Implements net.sf.ehcache.Ehcache.unregisterCacheExtension.

Unregister a CacheExtension with the cache.
public void
unregisterCacheLoader(CacheLoader
A Cache Loader to unregister
cacheLoader
)

Implements net.sf.ehcache.Ehcache.unregisterCacheLoader.

Unregister a CacheLoader with the cache.
public void
public void
waitUntilClusterBulkLoadComplete()

Implements net.sf.ehcache.Ehcache.waitUntilClusterBulkLoadComplete.

This method waits until all the connected nodes have disabled bulk-load.
public void
waitUntilClusterCoherent()

Implements net.sf.ehcache.Ehcache.waitUntilClusterCoherent.

Deprecated Use waitUntilClusterBulkLoadComplete() instead
This method waits until the cache is in coherent mode in all the connected nodes.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait