org.xwiki.cache.util
Class AbstractCache<T>

java.lang.Object
  extended by org.xwiki.cache.util.AbstractCache<T>
Type Parameters:
T -
All Implemented Interfaces:
Cache<T>

public abstract class AbstractCache<T>
extends java.lang.Object
implements Cache<T>

Base class for Cache implementations. It provides events DisposableCacheValue management.

Version:
$Id$

Field Summary
protected  javax.swing.event.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
AbstractCache()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xwiki.cache.Cache
get, remove, removeAll, set
 

Field Detail

configuration

protected CacheConfiguration configuration
The configuration used to create the cache.


cacheEntryListeners

protected final javax.swing.event.EventListenerList cacheEntryListeners
The list of listener to called when events appends on a cache entry.

Constructor Detail

AbstractCache

public AbstractCache()
Method Detail

dispose

public void dispose()
Release all the resources this cache use.

Specified by:
dispose in interface Cache<T>
See Also:
Cache.dispose()

addCacheEntryListener

public void addCacheEntryListener(CacheEntryListener<T> listener)
Add the provided listener to the cache to catch events on entries like add, remove etc.

Specified by:
addCacheEntryListener in interface Cache<T>
Parameters:
listener - the implemented listener.
See Also:
Cache.addCacheEntryListener(org.xwiki.cache.event.CacheEntryListener)

removeCacheEntryListener

public void removeCacheEntryListener(CacheEntryListener<T> listener)
Remove the provided listener from the list of listeners.

Specified by:
removeCacheEntryListener in interface Cache<T>
Parameters:
listener - the implemented listener.
See Also:
Cache.removeCacheEntryListener(org.xwiki.cache.event.CacheEntryListener)

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


Copyright © 2004-2011 XWiki. All Rights Reserved.