org.mortbay.jetty
Class ResourceCache

java.lang.Object
  extended by org.mortbay.component.AbstractLifeCycle
      extended by org.mortbay.jetty.ResourceCache
All Implemented Interfaces:
Serializable, LifeCycle

public class ResourceCache
extends AbstractLifeCycle
implements Serializable

Author:
Greg Wilkins
See Also:
Serialized Form

Nested Class Summary
 class ResourceCache.Entry
          MetaData associated with a context Resource.
static interface ResourceCache.Value
           
 
Field Summary
protected  Map _cache
           
protected  int _cachedFiles
           
protected  int _cacheSize
           
protected  ResourceCache.Entry _leastRecentlyUsed
           
private  int _maxCachedFiles
           
private  int _maxCachedFileSize
           
private  int _maxCacheSize
           
protected  ResourceCache.Entry _mostRecentlyUsed
           
 
Constructor Summary
ResourceCache()
          Constructor.
 
Method Summary
 void doStart()
           
 void doStop()
          Stop the context.
 void flushCache()
           
 int getMaxCachedFiles()
           
 int getMaxCachedFileSize()
           
 int getMaxCacheSize()
           
 ResourceCache.Entry lookup(String pathInContext, ResourceFactory factory)
          Get a Entry from the cache.
 void setMaxCachedFiles(int maxCachedFiles)
           
 void setMaxCachedFileSize(int maxCachedFileSize)
           
 void setMaxCacheSize(int maxCacheSize)
           
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_maxCachedFileSize

private int _maxCachedFileSize

_maxCachedFiles

private int _maxCachedFiles

_maxCacheSize

private int _maxCacheSize

_cache

protected transient Map _cache

_cacheSize

protected transient int _cacheSize

_cachedFiles

protected transient int _cachedFiles

_mostRecentlyUsed

protected transient ResourceCache.Entry _mostRecentlyUsed

_leastRecentlyUsed

protected transient ResourceCache.Entry _leastRecentlyUsed
Constructor Detail

ResourceCache

public ResourceCache()
Constructor.

Method Detail

getMaxCachedFileSize

public int getMaxCachedFileSize()

setMaxCachedFileSize

public void setMaxCachedFileSize(int maxCachedFileSize)

getMaxCacheSize

public int getMaxCacheSize()

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSize)

getMaxCachedFiles

public int getMaxCachedFiles()
Returns:
Returns the maxCachedFiles.

setMaxCachedFiles

public void setMaxCachedFiles(int maxCachedFiles)
Parameters:
maxCachedFiles - The maxCachedFiles to set.

flushCache

public void flushCache()

lookup

public ResourceCache.Entry lookup(String pathInContext,
                                  ResourceFactory factory)
Get a Entry from the cache. Get either a valid entry object or create a new one if possible. When an non-new entry is found, the thread will wait until a non-null value is set on the entry. It is the responsibility of the thread that creates an entry to set the value.

Parameters:
pathInContext -
resource -
value - associated value
Throws:
IOException

doStart

public void doStart()
             throws Exception
Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception

doStop

public void doStop()
            throws InterruptedException
Stop the context.

Overrides:
doStop in class AbstractLifeCycle
Throws:
InterruptedException