org.apache.jetspeed.cache.impl
Class EhDecorationContentCacheImpl

java.lang.Object
  extended by org.apache.jetspeed.cache.impl.EhCacheImpl
      extended by org.apache.jetspeed.cache.impl.EhDecorationContentCacheImpl
All Implemented Interfaces:
JetspeedCache, JetspeedCacheEventListener, JetspeedContentCache

public class EhDecorationContentCacheImpl
extends EhCacheImpl
implements JetspeedContentCache, JetspeedCacheEventListener

Wrapper around actual cache implementation

Version:
$Id: $
Author:
David Sean Taylor

Field Summary
static java.lang.String KEY_THEME_KEY
           
static int KEY_THEME_KEY_LENGTH
           
 
Fields inherited from class org.apache.jetspeed.cache.impl.EhCacheImpl
ehcache, localListeners, remoteListeners
 
Constructor Summary
EhDecorationContentCacheImpl(net.sf.ehcache.Cache ehcache, ContentCacheKeyGenerator keyGenerator)
           
EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache)
           
EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache, JetspeedCache preferenceCache)
           
EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache, JetspeedCache preferenceCache, ContentCacheKeyGenerator keyGenerator)
           
 
Method Summary
 void clear()
          clear all content in the cache
 ContentCacheKey createCacheKey(RequestContext context, java.lang.String windowId)
          Create a portlet content cache key based on dynamic request context information and a window id
 CacheElement createElement(java.lang.Object key, java.lang.Object content)
          Create a cached element
 java.lang.String createSessionKey(RequestContext context)
          Creates a session key used to store associated information in the session.
 void evictContentForSession(java.lang.String session)
          Evict all cached content for the given session identifier
 void evictContentForUser(java.lang.String username)
          Evict all cached content for the given username
 CacheElement get(java.lang.Object key)
          Retrieve an object from the cache
 int getTimeToIdleSeconds()
           
 int getTimeToLiveSeconds()
           
 void invalidate(RequestContext context)
          remove from the cache and invalidate any associated caches or session attributes
 boolean isKeyInCache(java.lang.Object key)
           
 void notifyElementAdded(JetspeedCache cache, boolean local, java.lang.Object key, java.lang.Object element)
          ADDED notification for cache listeners
 void notifyElementChanged(JetspeedCache cache, boolean local, java.lang.Object key, java.lang.Object element)
          CHANGE notification for cache listeners
 void notifyElementEvicted(JetspeedCache cache, boolean local, java.lang.Object key, java.lang.Object element)
          EVICTED notification for cache listeners
 void notifyElementExpired(JetspeedCache cache, boolean local, java.lang.Object key, java.lang.Object element)
          EXPIRED notification for cache listeners
 void notifyElementRemoved(JetspeedCache cache, boolean local, java.lang.Object key, java.lang.Object element)
          REMOVE notification for cache listeners
 void put(CacheElement element)
          Put an object into the cache, adding it, or replacing if exists
 boolean remove(java.lang.Object key)
          Remove an object from the cache
protected  net.sf.ehcache.Element saveGet(java.lang.Object key)
           
 
Methods inherited from class org.apache.jetspeed.cache.impl.EhCacheImpl
addEventListener, clone, dispose, notifyListeners, removeEventListener, removeQuiet
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.cache.JetspeedCache
addEventListener, removeEventListener, removeQuiet
 

Field Detail

KEY_THEME_KEY

public static final java.lang.String KEY_THEME_KEY
See Also:
Constant Field Values

KEY_THEME_KEY_LENGTH

public static final int KEY_THEME_KEY_LENGTH
Constructor Detail

EhDecorationContentCacheImpl

public EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache,
                                    JetspeedCache preferenceCache,
                                    ContentCacheKeyGenerator keyGenerator)

EhDecorationContentCacheImpl

public EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache,
                                    JetspeedCache preferenceCache)

EhDecorationContentCacheImpl

public EhDecorationContentCacheImpl(net.sf.ehcache.Ehcache ehcache)

EhDecorationContentCacheImpl

public EhDecorationContentCacheImpl(net.sf.ehcache.Cache ehcache,
                                    ContentCacheKeyGenerator keyGenerator)
Method Detail

notifyElementAdded

public void notifyElementAdded(JetspeedCache cache,
                               boolean local,
                               java.lang.Object key,
                               java.lang.Object element)
Description copied from interface: JetspeedCacheEventListener
ADDED notification for cache listeners

Specified by:
notifyElementAdded in interface JetspeedCacheEventListener
Parameters:
cache - the Cache repoorting the change
local - true if action was local, false if initiated by remote cache
key - key of object
element - content of object

notifyElementChanged

public void notifyElementChanged(JetspeedCache cache,
                                 boolean local,
                                 java.lang.Object key,
                                 java.lang.Object element)
Description copied from interface: JetspeedCacheEventListener
CHANGE notification for cache listeners

Specified by:
notifyElementChanged in interface JetspeedCacheEventListener
Parameters:
cache - the Cache repoorting the change
local - true if action was local, false if initiated by remote cache
key - key of object
element - content of object

notifyElementEvicted

public void notifyElementEvicted(JetspeedCache cache,
                                 boolean local,
                                 java.lang.Object key,
                                 java.lang.Object element)
Description copied from interface: JetspeedCacheEventListener
EVICTED notification for cache listeners

Specified by:
notifyElementEvicted in interface JetspeedCacheEventListener
Parameters:
cache - the Cache repoorting the change
local - true if action was local, false if initiated by remote cache
key - key of object
element - content of object

notifyElementExpired

public void notifyElementExpired(JetspeedCache cache,
                                 boolean local,
                                 java.lang.Object key,
                                 java.lang.Object element)
Description copied from interface: JetspeedCacheEventListener
EXPIRED notification for cache listeners

Specified by:
notifyElementExpired in interface JetspeedCacheEventListener
Parameters:
cache - the Cache repoorting the change
local - true if action was local, false if initiated by remote cache
key - key of object
element - content of object

notifyElementRemoved

public void notifyElementRemoved(JetspeedCache cache,
                                 boolean local,
                                 java.lang.Object key,
                                 java.lang.Object element)
Description copied from interface: JetspeedCacheEventListener
REMOVE notification for cache listeners

Specified by:
notifyElementRemoved in interface JetspeedCacheEventListener
Parameters:
cache - the Cache repoorting the change
local - true if action was local, false if initiated by remote cache
key - key of object
element - content of object

get

public CacheElement get(java.lang.Object key)
Description copied from interface: JetspeedCache
Retrieve an object from the cache

Specified by:
get in interface JetspeedCache
Overrides:
get in class EhCacheImpl
Parameters:
key - The key used to find the object
Returns:
the found object or null

getTimeToIdleSeconds

public int getTimeToIdleSeconds()
Specified by:
getTimeToIdleSeconds in interface JetspeedCache
Overrides:
getTimeToIdleSeconds in class EhCacheImpl
Returns:
the default idle time in seconds for this cache

getTimeToLiveSeconds

public int getTimeToLiveSeconds()
Specified by:
getTimeToLiveSeconds in interface JetspeedCache
Overrides:
getTimeToLiveSeconds in class EhCacheImpl
Returns:
the default idle time in seconds for this cache

isKeyInCache

public boolean isKeyInCache(java.lang.Object key)
Specified by:
isKeyInCache in interface JetspeedCache
Overrides:
isKeyInCache in class EhCacheImpl

put

public void put(CacheElement element)
Description copied from interface: JetspeedCache
Put an object into the cache, adding it, or replacing if exists

Specified by:
put in interface JetspeedCache
Overrides:
put in class EhCacheImpl

createElement

public CacheElement createElement(java.lang.Object key,
                                  java.lang.Object content)
Description copied from interface: JetspeedCache
Create a cached element

Specified by:
createElement in interface JetspeedCache
Overrides:
createElement in class EhCacheImpl
Returns:

remove

public boolean remove(java.lang.Object key)
Description copied from interface: JetspeedCache
Remove an object from the cache

Specified by:
remove in interface JetspeedCache
Overrides:
remove in class EhCacheImpl
Returns:
true if the object was removed, false otherwise

evictContentForUser

public void evictContentForUser(java.lang.String username)
Description copied from interface: JetspeedCache
Evict all cached content for the given username

Specified by:
evictContentForUser in interface JetspeedCache
Overrides:
evictContentForUser in class EhCacheImpl
Parameters:
username - unique user identifier

evictContentForSession

public void evictContentForSession(java.lang.String session)
Description copied from interface: JetspeedCache
Evict all cached content for the given session identifier

Specified by:
evictContentForSession in interface JetspeedCache
Overrides:
evictContentForSession in class EhCacheImpl

clear

public void clear()
Description copied from interface: JetspeedCache
clear all content in the cache

Specified by:
clear in interface JetspeedCache
Overrides:
clear in class EhCacheImpl

createCacheKey

public ContentCacheKey createCacheKey(RequestContext context,
                                      java.lang.String windowId)
Description copied from interface: JetspeedCache
Create a portlet content cache key based on dynamic request context information and a window id

Specified by:
createCacheKey in interface JetspeedCache
Overrides:
createCacheKey in class EhCacheImpl
Returns:

saveGet

protected net.sf.ehcache.Element saveGet(java.lang.Object key)

createSessionKey

public java.lang.String createSessionKey(RequestContext context)
Description copied from interface: JetspeedContentCache
Creates a session key used to store associated information in the session.

Specified by:
createSessionKey in interface JetspeedContentCache
Returns:

invalidate

public void invalidate(RequestContext context)
Description copied from interface: JetspeedContentCache
remove from the cache and invalidate any associated caches or session attributes

Specified by:
invalidate in interface JetspeedContentCache


Copyright © 1999-2009 Apache Software Foundation. All Rights Reserved.