Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.concurrency.caching
Class ReferenceEntityCache

    java.lang.Object
      org.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.16.2.2 $
Author:
  Dan Ellentuck
See Also:
  `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

### log

    protected final org.apache.commons.logging.Log log

  Commons Logging instance configured to log as the runtime class. Available to subclasses for logging, and used in the implementation of debug() so that debug messages will log as the runtime class.

### cache

    protected java.util.Map cache

### entityType

    protected java.lang.Class entityType

### simpleTypeName

    protected java.lang.String simpleTypeName

### threadID

    protected static int threadID

### sweepIntervalMillis

    protected int sweepIntervalMillis

### cleanupThread

    protected java.lang.Thread cleanupThread

Constructor Detail

### ReferenceEntityCache

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

  ReferenceEntityCache constructor comment.

  Throws:
    `CachingException`

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`

### initializeEntityType

    private void initializeEntityType(java.lang.Class type)
                               throws CachingException

  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`

### debug

    void debug(java.lang.String msg)

  Deprecated. Use Commons Logging directly.

  Print a debug message prepended with the current time.

  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.

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

### getCache

    protected java.util.Map getCache()

  Returns:
    java.util.Map

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

### setCache

    protected void setCache(java.util.Map newCache)

  Parameters:
    `newCache` - java.util.Map

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

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of the receiver

### getSimpleTypeName

    private java.lang.String getSimpleTypeName()

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD