org.apache.portals.applications.transform.impl
Class MemoryTransformCache

java.lang.Object
  extended byorg.apache.portals.applications.transform.impl.MemoryTransformCache
All Implemented Interfaces:
Comparator, Observer, TransformCache

public class MemoryTransformCache
extends Object
implements TransformCache

TransformCacheComponent

Version:
$Id: MemoryTransformCache.java 187949 2004-11-15 06:06:42Z taylor $
Author:
David Sean Taylor

Field Summary
private  TreeMap cache
           
private  boolean debug
           
private  boolean enable
           
private  int evictionPercentage
           
private  Object lock
           
private  int maxSize
           
private  Transform transform
           
 
Constructor Summary
MemoryTransformCache(Transform transform, int maxSize, int evictionPercentage, boolean enable, boolean debug)
          Spring constructor injection
 
Method Summary
 void clearCache()
          Clear the Transform Cache
 int compare(Object o1, Object o2)
           
 String constructKey(String url, String stylesheet)
          Construct the key for the TransformDocumentTreeMap cache
protected  void evict()
          The eviction policy will keep n items in the cache, and then start evicting x items ordered-by least used first.
 TransformCacheEntry get(String key)
          Retrieve the unique TransformCacheEntry keyed off with key
 Object getDocument(String key)
          Retrieve the byte[] storing the transformed content for the transfomId and the documentId combination.
 int getEvictionPercentage()
          Get the eviction percentage of the cache
 int getMaxSize()
          Get the maximum size of the cache
 boolean isEnabled()
          Find out if TransformCache is enables
 void put(String key, Object document, long timeToLive)
          Put a value in the TransformCache keyed off with the TransformId and the DocumentId.
 Object remove(String key)
          Remove a unique value keyed off with the TransformId and DocumentId from the cache.
 void setMaxSize(int maxSize)
          Set the new maximum size of the cache
 void update(Observable o, Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

debug

private boolean debug

maxSize

private int maxSize

evictionPercentage

private int evictionPercentage

enable

private boolean enable

transform

private Transform transform

cache

private TreeMap cache

lock

private Object lock
Constructor Detail

MemoryTransformCache

public MemoryTransformCache(Transform transform,
                            int maxSize,
                            int evictionPercentage,
                            boolean enable,
                            boolean debug)
Spring constructor injection

Method Detail

getMaxSize

public int getMaxSize()
Description copied from interface: TransformCache
Get the maximum size of the cache

Specified by:
getMaxSize in interface TransformCache
Returns:
the current maximum size of the cache

setMaxSize

public void setMaxSize(int maxSize)
Description copied from interface: TransformCache
Set the new maximum size of the cache

Specified by:
setMaxSize in interface TransformCache
Parameters:
maxSize - the maximum size of the cache

getEvictionPercentage

public int getEvictionPercentage()
Description copied from interface: TransformCache
Get the eviction percentage of the cache

Specified by:
getEvictionPercentage in interface TransformCache
Returns:
the eviction percentage of the cache

isEnabled

public boolean isEnabled()
Description copied from interface: TransformCache
Find out if TransformCache is enables

Specified by:
isEnabled in interface TransformCache
Returns:
the enable flag of the cache

put

public void put(String key,
                Object document,
                long timeToLive)
Description copied from interface: TransformCache
Put a value in the TransformCache keyed off with the TransformId and the DocumentId.

Specified by:
put in interface TransformCache
Parameters:
key -
document -

evict

protected void evict()
The eviction policy will keep n items in the cache, and then start evicting x items ordered-by least used first. n = max size of cache x = (eviction_percentage/100) * n


remove

public Object remove(String key)
Description copied from interface: TransformCache
Remove a unique value keyed off with the TransformId and DocumentId from the cache.

Specified by:
remove in interface TransformCache
Parameters:
key -
Returns:
Object

get

public TransformCacheEntry get(String key)
Description copied from interface: TransformCache
Retrieve the unique TransformCacheEntry keyed off with key

Specified by:
get in interface TransformCache
Parameters:
key -
Returns:
TransformCacheEntry

getDocument

public Object getDocument(String key)
Description copied from interface: TransformCache
Retrieve the byte[] storing the transformed content for the transfomId and the documentId combination.

Specified by:
getDocument in interface TransformCache
Returns:
Object

compare

public int compare(Object o1,
                   Object o2)
Specified by:
compare in interface Comparator

constructKey

public String constructKey(String url,
                           String stylesheet)
Description copied from interface: TransformCache
Construct the key for the TransformDocumentTreeMap cache

Specified by:
constructKey in interface TransformCache
Returns:
String

clearCache

public void clearCache()
Description copied from interface: TransformCache
Clear the Transform Cache

Specified by:
clearCache in interface TransformCache

update

public void update(Observable o,
                   Object arg)
Specified by:
update in interface Observer


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