uPortal 2.4.1
API Documentation

org.jasig.portal.concurrency.caching
Class ReferenceEntityCache

java.lang.Object
  extended byorg.jasig.portal.concurrency.caching.ReferenceEntityCache
All Implemented Interfaces:
IEntityCache
Direct Known Subclasses:
ReferenceInvalidatingEntityCache

public class ReferenceEntityCache
extends java.lang.Object
implements IEntityCache

Reference implementation of IEntityCache. Each cache holds entities of a single type in an LRUCache, a kind of HashMap. Synchronization for get(), add() and remove() is handled by the LRUCache. At intervals, the cleanupThread kicks off a sweep of the cache to trim it down to its maximum size.

Version:
$Revision: 1.12 $
Author:
Dan Ellentuck
See Also:
LRUCache

Constructor Summary
ReferenceEntityCache(java.lang.Class type, int maxSize, int maxUnusedTime, int sweepInterval)
          ReferenceEntityCache constructor comment.
 
Method Summary
 void add(IBasicEntity entity)
          Checks that entity is the same type as, i.e., could be cast to, the cache type.
 void cleanupCache()
          Remove stale entries from the cache.
 void clearCache()
          Remove all entries from the cache.
 IBasicEntity get(java.lang.String key)
           
 java.lang.Class getEntityType()
           
 void remove(java.lang.String key)
           
 int size()
          Answers the number of entries in the cache.
 java.lang.String toString()
          Returns a String that represents the value of this object.
 void update(IBasicEntity entity)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceEntityCache

public ReferenceEntityCache(java.lang.Class type,
                            int maxSize,
                            int maxUnusedTime,
                            int sweepInterval)
                     throws CachingException
ReferenceEntityCache constructor comment.

Method Detail

add

public void add(IBasicEntity entity)
         throws CachingException
Checks that entity is the same type as, i.e., could be cast to, the cache type.

Specified by:
add in interface IEntityCache
Parameters:
entity - the entity to be added to the cache.
Throws:
CachingException

cleanupCache

public void cleanupCache()
Remove stale entries from the cache.

Specified by:
cleanupCache in interface IEntityCache

clearCache

public void clearCache()
Remove all entries from the cache.

Specified by:
clearCache in interface IEntityCache

get

public IBasicEntity get(java.lang.String key)
Specified by:
get in interface IEntityCache
Parameters:
key - the key of the entity.
Returns:
org.jasig.portal.concurrency.IBasicEntity

getEntityType

public final java.lang.Class getEntityType()
Specified by:
getEntityType in interface IEntityCache
Returns:
java.lang.Class
See Also:
for known types.

remove

public void remove(java.lang.String key)
            throws CachingException
Specified by:
remove in interface IEntityCache
Parameters:
key - the key of the entity to be un-cached.
Throws:
CachingException

size

public int size()
Description copied from interface: IEntityCache
Answers the number of entries in the cache.

Specified by:
size in interface IEntityCache
Returns:
int

toString

public java.lang.String toString()
Returns a String that represents the value of this object.

Returns:
a string representation of the receiver

update

public void update(IBasicEntity entity)
            throws CachingException
Specified by:
update in interface IEntityCache
Parameters:
entity - the entity to be updated in the cache.
Throws:
CachingException

uPortal 2.4.1
API Documentation