fr.paris.lutece.portal.service.cache
Class AbstractCacheableService

java.lang.Object
  extended by fr.paris.lutece.portal.service.cache.AbstractCacheableService
All Implemented Interfaces:
CacheableService, LuteceService, java.lang.Cloneable, net.sf.ehcache.event.CacheEventListener
Direct Known Subclasses:
ContentService, PageCacheService, PortalMenuService, PortletCacheService, ResourceService, SiteMapApp

public abstract class AbstractCacheableService
extends java.lang.Object
implements CacheableService, net.sf.ehcache.event.CacheEventListener

Base implementation for a cacheable service


Constructor Summary
AbstractCacheableService()
           
 
Method Summary
 java.lang.Object clone()
           
 void dispose()
          
 void enableCache(boolean bEnable)
          Enable the cache
 net.sf.ehcache.Cache getCache()
          Return a cache object
 int getCacheSize()
          Gets the number of item currently in the cache.
 java.lang.Object getFromCache(java.lang.String strKey)
          Gets an object from the cache
 java.lang.String getInfos()
          Returns cache infos
 java.util.List<java.lang.String> getKeys()
          Gets all keys in the cache
 int getMaxElements()
          Returns maximum elements accepted into the cache
 long getMemorySize()
          Return the memory size
 long getTimeToLive()
          Returns the time to live for objects in the cache
 void initCache()
          Init the cache.
 void initCache(java.lang.String strCacheName)
          Init the cache.
 boolean isCacheEnable()
          Gets the current cache status.
 void notifyElementEvicted(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)
          
 void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyElementPut(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)
          
 void notifyElementRemoved(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)
          
 void notifyElementUpdated(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)
          
 void notifyRemoveAll(net.sf.ehcache.Ehcache ehch)
          
 void putInCache(java.lang.String strKey, java.lang.Object object)
          Put an object into the cache
 void resetCache()
          Reset the cache.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.paris.lutece.portal.service.util.LuteceService
getName
 

Constructor Detail

AbstractCacheableService

public AbstractCacheableService()
Method Detail

initCache

public void initCache()
Init the cache. Should be called by the service at its initialization.


initCache

public void initCache(java.lang.String strCacheName)
Init the cache. Should be called by the service at its initialization.

Parameters:
strCacheName - The cache name

putInCache

public void putInCache(java.lang.String strKey,
                       java.lang.Object object)
Put an object into the cache

Parameters:
strKey - The key of the object to put into the cache
object - The object to put into the cache

getFromCache

public java.lang.Object getFromCache(java.lang.String strKey)
Gets an object from the cache

Parameters:
strKey - The key of the object to retrieve from the cache
Returns:
The object from the cache

isCacheEnable

public boolean isCacheEnable()
Gets the current cache status.

Specified by:
isCacheEnable in interface CacheableService
Returns:
true if enable, otherwise false

enableCache

public void enableCache(boolean bEnable)
Enable the cache

Specified by:
enableCache in interface CacheableService
Parameters:
bEnable - true to enable, false to disable

resetCache

public void resetCache()
Reset the cache.

Specified by:
resetCache in interface CacheableService

getCacheSize

public int getCacheSize()
Gets the number of item currently in the cache.

Specified by:
getCacheSize in interface CacheableService
Returns:
the number of item currently in the cache.

getCache

public net.sf.ehcache.Cache getCache()
Return a cache object

Returns:
cache object

getKeys

public java.util.List<java.lang.String> getKeys()
Gets all keys in the cache

Specified by:
getKeys in interface CacheableService
Returns:
The List

getMaxElements

public int getMaxElements()
Returns maximum elements accepted into the cache

Specified by:
getMaxElements in interface CacheableService
Returns:
The max elements

getTimeToLive

public long getTimeToLive()
Returns the time to live for objects in the cache

Specified by:
getTimeToLive in interface CacheableService
Returns:
The time to live in seconds

getMemorySize

public long getMemorySize()
Return the memory size

Specified by:
getMemorySize in interface CacheableService
Returns:
the memory size

getInfos

public java.lang.String getInfos()
Returns cache infos

Specified by:
getInfos in interface CacheableService
Returns:
cache infos

clone

public java.lang.Object clone()
Specified by:
clone in interface net.sf.ehcache.event.CacheEventListener
Overrides:
clone in class java.lang.Object
Returns:
the instance
See Also:
Object.clone()

notifyElementExpired

public void notifyElementExpired(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)

Specified by:
notifyElementExpired in interface net.sf.ehcache.event.CacheEventListener

notifyElementRemoved

public void notifyElementRemoved(net.sf.ehcache.Ehcache ehch,
                                 net.sf.ehcache.Element elmnt)
                          throws net.sf.ehcache.CacheException

Specified by:
notifyElementRemoved in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementEvicted

public void notifyElementEvicted(net.sf.ehcache.Ehcache ehch,
                                 net.sf.ehcache.Element elmnt)

Specified by:
notifyElementEvicted in interface net.sf.ehcache.event.CacheEventListener

notifyRemoveAll

public void notifyRemoveAll(net.sf.ehcache.Ehcache ehch)

Specified by:
notifyRemoveAll in interface net.sf.ehcache.event.CacheEventListener

notifyElementPut

public void notifyElementPut(net.sf.ehcache.Ehcache ehch,
                             net.sf.ehcache.Element elmnt)
                      throws net.sf.ehcache.CacheException

Specified by:
notifyElementPut in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementUpdated

public void notifyElementUpdated(net.sf.ehcache.Ehcache ehch,
                                 net.sf.ehcache.Element elmnt)
                          throws net.sf.ehcache.CacheException

Specified by:
notifyElementUpdated in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

dispose

public void dispose()

Specified by:
dispose in interface net.sf.ehcache.event.CacheEventListener


Copyright © 2011 Mairie de Paris. All Rights Reserved.