org.exoplatform.services.cache
Class BaseExoCache

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap
              extended by org.exoplatform.services.cache.BaseExoCache
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, ExoCache
Direct Known Subclasses:
FIFOExoCache, SimpleExoCache

public abstract class BaseExoCache
extends java.util.LinkedHashMap
implements ExoCache

Created by The eXo Platform SAS Author : Tuan Nguyen tuan08@users.sourceforge.net Sat, Sep 13, 2003 @ Time: 1:12:22 PM

See Also:
Serialized Form

Constructor Summary
BaseExoCache()
           
BaseExoCache(int maxSize)
           
BaseExoCache(java.lang.String name, int maxSize)
           
 
Method Summary
 void addCacheListener(CacheListener listener)
           
 void clearCache()
          Clears the cache.
protected abstract  ObjectCacheInfo createObjectCacheInfo(long expTime, java.lang.Object objToCache)
           
 java.lang.Object get(java.io.Serializable name)
          Performs a lookup operation.
 java.util.List getCachedObjects()
          Returns a list of cached object that are considered as valid when the method is called.
 int getCacheHit()
           
 int getCacheMiss()
           
 int getCacheSize()
           
 java.lang.String getLabel()
           
 long getLiveTime()
           
 int getMaxSize()
           
 java.lang.String getName()
           
 boolean isDistributed()
           
 boolean isLogEnabled()
           
 boolean isReplicated()
           
 void localClear()
           
 void localPut(java.io.Serializable key, java.lang.Object obj)
           
 java.lang.Object localRemove(java.io.Serializable key)
           
 void put(java.io.Serializable name, java.lang.Object obj)
          Performs a put in the cache.
 void putMap(java.util.Map<java.io.Serializable,java.lang.Object> objs)
          For whole put of items set
 java.lang.Object remove(java.io.Serializable name)
          Removes an entry from the cache.
 java.util.List removeCachedObjects()
          Clears the cache and returns the list of cached object that are considered as valid when the method is called.
protected  boolean removeEldestEntry(java.util.Map.Entry eldest)
           
 void select(CachedObjectSelector selector)
          Selects a subset of the cache.
 void setDistributed(boolean b)
           
 void setLabel(java.lang.String name)
           
 void setLiveTime(long period)
           
 void setLogEnabled(boolean b)
           
 void setMaxSize(int max)
           
 void setName(java.lang.String s)
           
 void setReplicated(boolean b)
           
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

BaseExoCache

public BaseExoCache()

BaseExoCache

public BaseExoCache(int maxSize)

BaseExoCache

public BaseExoCache(java.lang.String name,
                    int maxSize)
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface ExoCache

setName

public void setName(java.lang.String s)
Specified by:
setName in interface ExoCache

getLabel

public java.lang.String getLabel()
Specified by:
getLabel in interface ExoCache

setLabel

public void setLabel(java.lang.String name)
Specified by:
setLabel in interface ExoCache

getCacheSize

public int getCacheSize()
Specified by:
getCacheSize in interface ExoCache

getMaxSize

public int getMaxSize()
Specified by:
getMaxSize in interface ExoCache

setMaxSize

public void setMaxSize(int max)
Specified by:
setMaxSize in interface ExoCache

getLiveTime

public long getLiveTime()
Specified by:
getLiveTime in interface ExoCache

setLiveTime

public void setLiveTime(long period)
Specified by:
setLiveTime in interface ExoCache

get

public java.lang.Object get(java.io.Serializable name)
                     throws java.lang.Exception
Description copied from interface: ExoCache
Performs a lookup operation.

Specified by:
get in interface ExoCache
Parameters:
name - the cache key
Returns:
the cached value which may be evaluated to null
Throws:
java.lang.Exception - any exception

remove

public java.lang.Object remove(java.io.Serializable name)
                        throws java.lang.Exception
Description copied from interface: ExoCache
Removes an entry from the cache.

Specified by:
remove in interface ExoCache
Parameters:
name - the cache key
Returns:
the previously cached value or null if no entry existed or that entry value was evaluated to null
Throws:
java.lang.Exception - any exception

select

public void select(CachedObjectSelector selector)
            throws java.lang.Exception
Description copied from interface: ExoCache
Selects a subset of the cache.

Specified by:
select in interface ExoCache
Parameters:
selector - the selector
Throws:
java.lang.Exception - any exception

put

public void put(java.io.Serializable name,
                java.lang.Object obj)
         throws java.lang.Exception
Description copied from interface: ExoCache
Performs a put in the cache.

Specified by:
put in interface ExoCache
Parameters:
name - the cache key
obj - the cached value
Throws:
java.lang.Exception - any exception

putMap

public void putMap(java.util.Map<java.io.Serializable,java.lang.Object> objs)
            throws java.lang.Exception
For whole put of items set

Specified by:
putMap in interface ExoCache
Parameters:
objs - the objects to put
Throws:
java.lang.Exception - any exception

clearCache

public void clearCache()
                throws java.lang.Exception
Description copied from interface: ExoCache
Clears the cache.

Specified by:
clearCache in interface ExoCache
Throws:
java.lang.Exception - any exception

getCacheHit

public int getCacheHit()
Specified by:
getCacheHit in interface ExoCache

getCacheMiss

public int getCacheMiss()
Specified by:
getCacheMiss in interface ExoCache

isDistributed

public boolean isDistributed()
Specified by:
isDistributed in interface ExoCache

setDistributed

public void setDistributed(boolean b)
Specified by:
setDistributed in interface ExoCache

isReplicated

public boolean isReplicated()
Specified by:
isReplicated in interface ExoCache

setReplicated

public void setReplicated(boolean b)
Specified by:
setReplicated in interface ExoCache

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry eldest)
Overrides:
removeEldestEntry in class java.util.LinkedHashMap

getCachedObjects

public java.util.List getCachedObjects()
Description copied from interface: ExoCache
Returns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returnted.

Specified by:
getCachedObjects in interface ExoCache
Returns:
the list of cached objects

removeCachedObjects

public java.util.List removeCachedObjects()
                                   throws java.lang.Exception
Description copied from interface: ExoCache
Clears the cache and returns the list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.

Specified by:
removeCachedObjects in interface ExoCache
Returns:
the list of cached objects
Throws:
java.lang.Exception - any exception

addCacheListener

public void addCacheListener(CacheListener listener)
Specified by:
addCacheListener in interface ExoCache

localPut

public void localPut(java.io.Serializable key,
                     java.lang.Object obj)
              throws java.lang.Exception
Throws:
java.lang.Exception

localRemove

public java.lang.Object localRemove(java.io.Serializable key)
                             throws java.lang.Exception
Throws:
java.lang.Exception

localClear

public void localClear()
                throws java.lang.Exception
Throws:
java.lang.Exception

isLogEnabled

public boolean isLogEnabled()
Specified by:
isLogEnabled in interface ExoCache

setLogEnabled

public void setLogEnabled(boolean b)
Specified by:
setLogEnabled in interface ExoCache

createObjectCacheInfo

protected abstract ObjectCacheInfo createObjectCacheInfo(long expTime,
                                                         java.lang.Object objToCache)


Copyright © 2012 eXo Platform SAS. All Rights Reserved.