|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.concurrency.caching.ReferenceEntityCache
public class ReferenceEntityCache
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.
LRUCache| Nested Class Summary | |
|---|---|
protected class |
ReferenceEntityCache.CacheSweeper
|
| Field Summary | |
|---|---|
protected java.util.Map |
cache
|
protected java.lang.Thread |
cleanupThread
|
protected java.lang.Class |
entityType
|
protected org.apache.commons.logging.Log |
log
Commons Logging instance configured to log as the runtime class. |
protected java.lang.String |
simpleTypeName
|
protected int |
sweepIntervalMillis
|
protected static int |
threadID
|
| 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. |
(package private) void |
debug(java.lang.String msg)
Deprecated. Use Commons Logging directly. |
IBasicEntity |
get(java.lang.String key)
|
protected java.util.Map |
getCache()
|
java.lang.Class |
getEntityType()
|
private java.lang.String |
getSimpleTypeName()
|
private void |
initializeEntityType(java.lang.Class type)
|
void |
remove(java.lang.String key)
|
protected void |
setCache(java.util.Map newCache)
|
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final org.apache.commons.logging.Log log
protected java.util.Map cache
protected java.lang.Class entityType
protected java.lang.String simpleTypeName
protected static int threadID
protected int sweepIntervalMillis
protected java.lang.Thread cleanupThread
| Constructor Detail |
|---|
public ReferenceEntityCache(java.lang.Class type,
int maxSize,
int maxUnusedTime,
int sweepInterval)
throws CachingException
CachingException| Method Detail |
|---|
public void add(IBasicEntity entity)
throws CachingException
entity is the same type as, i.e., could be cast
to, the cache type.
add in interface IEntityCacheentity - the entity to be added to the cache.
CachingException
private void initializeEntityType(java.lang.Class type)
throws CachingException
CachingExceptionpublic void cleanupCache()
cleanupCache in interface IEntityCachepublic void clearCache()
clearCache in interface IEntityCachevoid debug(java.lang.String msg)
This method is deprecated. Instead use Commons Logging directly. Backing logging implementations such as log4j have capabilities for including (and formatting) the timestamps of log entries without that timestamp being explicitly generated here in the logging client.
While this method internally guards against needless additional object
creation, code calling this method should itself use the isDebugEnabled()
guard in order to avoid generating intermediary Strings as the msg
argument to this method.
public IBasicEntity get(java.lang.String key)
get in interface IEntityCachekey - the key of the entity.
protected java.util.Map getCache()
public final java.lang.Class getEntityType()
getEntityType in interface IEntityCachefor known types.
public void remove(java.lang.String key)
throws CachingException
remove in interface IEntityCachekey - the key of the entity to be un-cached.
CachingExceptionprotected void setCache(java.util.Map newCache)
newCache - java.util.Mappublic int size()
IEntityCache
size in interface IEntityCachepublic java.lang.String toString()
toString in class java.lang.Objectprivate java.lang.String getSimpleTypeName()
public void update(IBasicEntity entity)
throws CachingException
update in interface IEntityCacheentity - the entity to be updated in the cache.
CachingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||