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

public Class ClassLoaderAwareCache

extends Object
implements Ehcache
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.Ehcache, java.lang.Cloneable
Known Direct Subclasses
net.sf.ehcache.constructs.classloader.InternalClassLoaderAwareCache
Imports
java.beans.PropertyChangeListener, java.io.PrintStream, .Serializable, java.lang.reflect.Method, java.util.AbstractList, .Collection, .Collections, .Iterator, .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.TerracottaNotRunningException, net.sf.ehcache.transaction.manager.TransactionManagerLookup, net.sf.ehcache.writer.CacheWriter, .CacheWriterManager, org.terracotta.context.annotations.ContextChild

A cache decorator that adjusts the Thread context classloader (TCCL) for every cache operation. The TCCL is reset to its original value when the method is complete
Author
teck

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ClassLoaderAwareCache.ClassLoaderAwareIterator

Iterator needed for ClassLoaderAwareList

private class
ClassLoaderAwareCache.ClassLoaderAwareList

This class takes care of loading and unloading of classloader appropriately.

Field Summary

Modifier and TypeField and Description
protected final Ehcache
cache

Used by InternalClassLoaderAwareCache

protected final ClassLoader
classLoader

Used by InternalClassLoaderAwareCache

Constructor Summary

AccessConstructor and Description
public
ClassLoaderAwareCache(Ehcache
wrapped cache
cache
,
ClassLoader
loader to set Thread context loader to for duration of cache opeartion
classLoader
)

Constructor

Method Summary

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

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
arg0
)

Implements net.sf.ehcache.Ehcache.acquireWriteLockOnKey.

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

Implements net.sf.ehcache.Ehcache.addPropertyChangeListener.

Add a PropertyChangeListener.
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
arg0
)

Implements net.sf.ehcache.Ehcache.get.

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

Implements net.sf.ehcache.Ehcache.get.

Gets an element from the cache.
public Map<K, V>
getAll(Collection<E>
a collection of keys for which value is to be fetched
arg0
)

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
arg0
,
Object
an argument to pass to the CacheLoader.
arg1
)

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(Serializable
a serializable value
arg0
)

Implements net.sf.ehcache.Ehcache.getQuiet.

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

Implements net.sf.ehcache.Ehcache.getQuiet.

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

Implements net.sf.ehcache.Ehcache.getRegisteredCacheWriter.

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

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.
arg0
,
CacheLoader
the override loader to use. If null, the cache's default loader will be used
arg1
,
Object
an argument to pass to the CacheLoader.
arg2
)

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.

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
arg0
)

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
arg0
)

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
arg0
)

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
arg0
)

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
arg0
)

Implements net.sf.ehcache.Ehcache.isExpired.

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

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.

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

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
arg0
)

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
arg0
)

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.
arg0
)

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.
arg0
,
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

arg1
)

Implements net.sf.ehcache.Ehcache.loadAll.

The loadAll method provides a means to "pre load" objects into the cache.
public static void
main(String[] args)

Generator for the method bodies

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

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.
arg0
,
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
arg1
)

Implements net.sf.ehcache.Ehcache.put.

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

Implements net.sf.ehcache.Ehcache.putAll.

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

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(Element
element to be added
arg0
,
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
arg1
)

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.
arg0
)

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.
arg0
)

Implements net.sf.ehcache.Ehcache.putWithWriter.

Put an element in the cache writing through a CacheWriter.
public void
registerCacheExtension(CacheExtension
the cache extension
arg0
)

Implements net.sf.ehcache.Ehcache.registerCacheExtension.

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

Implements net.sf.ehcache.Ehcache.registerCacheLoader.

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

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
arg0
)

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
arg0
)

Implements net.sf.ehcache.Ehcache.releaseWriteLockOnKey.

Release a held write lock for the passed in key
public boolean
remove(Serializable
the key of the element to remove
arg0
,
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
arg1
)

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
arg0
)

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
arg0
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
public boolean
remove(Object
of the element to remove
arg0
,
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
arg1
)

Implements net.sf.ehcache.Ehcache.remove.

Removes an net.sf.ehcache.Element from the Cache.
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
arg0
)

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(Collection<E>
a collection of keys to operate on
arg0
,
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
arg1
)

Implements net.sf.ehcache.Ehcache.removeAll.

Removes all cached items.
public void
removeAll(Collection<E>
a collection of keys to operate on
arg0
)

Implements net.sf.ehcache.Ehcache.removeAll.

Removes given set of net.sf.ehcache.Element from the Cache.
public boolean
removeElement(Element
Element to be removed
arg0
)

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
arg0
)

Implements net.sf.ehcache.Ehcache.removePropertyChangeListener.

Remove a PropertyChangeListener.
public boolean
removeQuiet(Serializable
of the element to remove
arg0
)

Implements net.sf.ehcache.Ehcache.removeQuiet.

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

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
arg0
)

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 Element
replace(Element
Element to be cached
arg0
)

Implements net.sf.ehcache.Ehcache.replace.

Replace the cached element only if an Element is currently cached for this key
public boolean
replace(Element
Element to be test against
arg0
,
Element
Element to be cached
arg1
)

Implements net.sf.ehcache.Ehcache.replace.

Replace the cached element only if the current Element is equal to the supplied old Element.
public void
setBootstrapCacheLoader(BootstrapCacheLoader
the loader to be used
arg0
)

Implements net.sf.ehcache.Ehcache.setBootstrapCacheLoader.

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

Implements net.sf.ehcache.Ehcache.setCacheExceptionHandler.

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

Implements net.sf.ehcache.Ehcache.setCacheManager.

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

Implements net.sf.ehcache.Ehcache.setDisabled.

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

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
arg0
)

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
arg0
)

Implements net.sf.ehcache.Ehcache.setNodeCoherent.

Sets the cache in coherent or incoherent mode depending on the parameter on this node.
public void
setTransactionManagerLookup(TransactionManagerLookup
the transactionManagerLookup
arg0
)

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
arg0
,
long
- millis until giveup on getting the lock
arg1
)

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
arg0
,
long
- millis until giveup on getting the lock
arg1
)

Implements net.sf.ehcache.Ehcache.tryWriteLockOnKey.

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

Implements net.sf.ehcache.Ehcache.unregisterCacheExtension.

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

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.

This method waits until the cache is in coherent mode in all the connected nodes.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait