org.apache.jetspeed.cache.impl
Class EhCacheImpl

java.lang.Object
  extended by org.apache.jetspeed.cache.impl.EhCacheImpl
All Implemented Interfaces:
JetspeedCache
Direct Known Subclasses:
EhCacheDistributedImpl, EhDecorationContentCacheImpl, EhPortletContentCacheImpl, EhPortletWindowCache

public class EhCacheImpl
extends java.lang.Object
implements JetspeedCache


Field Summary
protected  net.sf.ehcache.Ehcache ehcache
           
protected  java.util.List localListeners
           
protected  java.util.List remoteListeners
           
 
Constructor Summary
EhCacheImpl(net.sf.ehcache.Ehcache ehcache)
           
 
Method Summary
 void addEventListener(JetspeedCacheEventListener listener, boolean local)
          Add a cache listener for supported cache events, either for local or remote cache events
 void clear()
          clear all content in the cache
 java.lang.Object clone()
           
 ContentCacheKey createCacheKey(RequestContext rc, 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
 void dispose()
           
 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()
           
 boolean isKeyInCache(java.lang.Object key)
           
protected  void notifyListeners(boolean local, int action, java.lang.Object key, java.lang.Object value)
           
 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
 void removeEventListener(JetspeedCacheEventListener listener, boolean local)
           
 boolean removeQuiet(java.lang.Object key)
          Remove object from cache, do not notify listeners
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ehcache

protected net.sf.ehcache.Ehcache ehcache

localListeners

protected java.util.List localListeners

remoteListeners

protected java.util.List remoteListeners
Constructor Detail

EhCacheImpl

public EhCacheImpl(net.sf.ehcache.Ehcache ehcache)
Method Detail

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
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
Returns:
the default idle time in seconds for this cache

getTimeToLiveSeconds

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

isKeyInCache

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

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

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
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
Returns:
true if the object was removed, false otherwise

removeQuiet

public boolean removeQuiet(java.lang.Object key)
Description copied from interface: JetspeedCache
Remove object from cache, do not notify listeners

Specified by:
removeQuiet in interface JetspeedCache
Returns:
trie if the object was removed, false otherwise

clear

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

Specified by:
clear in interface JetspeedCache

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
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

addEventListener

public void addEventListener(JetspeedCacheEventListener listener,
                             boolean local)
Description copied from interface: JetspeedCache
Add a cache listener for supported cache events, either for local or remote cache events

Specified by:
addEventListener in interface JetspeedCache
local - if true, listen to local events, if false, listen to remote

removeEventListener

public void removeEventListener(JetspeedCacheEventListener listener,
                                boolean local)
Specified by:
removeEventListener in interface JetspeedCache

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

dispose

public void dispose()

notifyListeners

protected void notifyListeners(boolean local,
                               int action,
                               java.lang.Object key,
                               java.lang.Object value)

createCacheKey

public ContentCacheKey createCacheKey(RequestContext rc,
                                      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
Returns:


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