Package org.xwiki.cache.util
Class AbstractCache<T>
- java.lang.Object
-
- org.xwiki.cache.util.AbstractCache<T>
-
- Type Parameters:
T
- the class of the data stored in the cache.
- All Implemented Interfaces:
Cache<T>
public abstract class AbstractCache<T> extends Object implements Cache<T>
Base class forCache
implementations. It provides eventsDisposableCacheValue
management.- Version:
- $Id: 0215579da91f5c992e51213a0604d939f3483c40 $
-
-
Field Summary
Fields Modifier and Type Field Description protected EventListenerList
cacheEntryListeners
The list of listener to called when events appends on a cache entry.protected CacheConfiguration
configuration
The configuration used to create the cache.
-
Constructor Summary
Constructors Constructor Description AbstractCache()
Deprecated.since 8.3RC1, useAbstractCache(CacheConfiguration)
insteadAbstractCache(CacheConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCacheEntryListener(CacheEntryListener<T> listener)
Add the provided listener to the cache to catch events on entries like add, remove etc.void
dispose()
Release all the resources this cache use.protected void
disposeCacheValue(T value)
Dispose the value being removed from the cache.void
removeCacheEntryListener(CacheEntryListener<T> listener)
Remove the provided listener from the list of listeners.protected void
sendEntryAddedEvent(CacheEntryEvent<T> event)
Helper method to send event when a new cache entry is inserted.protected void
sendEntryModifiedEvent(CacheEntryEvent<T> event)
Helper method to send event when a cache entry is modified.protected void
sendEntryRemovedEvent(CacheEntryEvent<T> event)
Helper method to send event when an existing cache entry is removed.
-
-
-
Field Detail
-
configuration
protected final CacheConfiguration configuration
The configuration used to create the cache.
-
cacheEntryListeners
protected final EventListenerList cacheEntryListeners
The list of listener to called when events appends on a cache entry.
-
-
Constructor Detail
-
AbstractCache
@Deprecated public AbstractCache()
Deprecated.since 8.3RC1, useAbstractCache(CacheConfiguration)
instead
-
AbstractCache
public AbstractCache(CacheConfiguration configuration)
- Parameters:
configuration
- the configuration of the cache
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:Cache
Release all the resources this cache use.
-
addCacheEntryListener
public void addCacheEntryListener(CacheEntryListener<T> listener)
Description copied from interface:Cache
Add the provided listener to the cache to catch events on entries like add, remove etc.- Specified by:
addCacheEntryListener
in interfaceCache<T>
- Parameters:
listener
- the implemented listener.
-
removeCacheEntryListener
public void removeCacheEntryListener(CacheEntryListener<T> listener)
Description copied from interface:Cache
Remove the provided listener from the list of listeners.- Specified by:
removeCacheEntryListener
in interfaceCache<T>
- Parameters:
listener
- the implemented listener.
-
sendEntryAddedEvent
protected void sendEntryAddedEvent(CacheEntryEvent<T> event)
Helper method to send event when a new cache entry is inserted.- Parameters:
event
- the event to send.
-
sendEntryRemovedEvent
protected void sendEntryRemovedEvent(CacheEntryEvent<T> event)
Helper method to send event when an existing cache entry is removed.- Parameters:
event
- the event to send.
-
sendEntryModifiedEvent
protected void sendEntryModifiedEvent(CacheEntryEvent<T> event)
Helper method to send event when a cache entry is modified.- Parameters:
event
- the event to send.
-
disposeCacheValue
protected void disposeCacheValue(T value)
Dispose the value being removed from the cache.- Parameters:
value
- the value to dispose
-
-