Top Inners Fields Constructors Methods
org.mortbay.jetty

public Class ResourceCache

extends AbstractLifeCycle
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
org.mortbay.jetty.servlet.NIOResourceCache
Imports
java.io.IOException, .InputStream, .Serializable, java.util.ArrayList, .HashMap, .Map, org.mortbay.component.AbstractLifeCycle, org.mortbay.io.Buffer, .ByteArrayBuffer, .View, org.mortbay.resource.Resource, .ResourceFactory

Author
Greg Wilkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
ResourceCache.Content

MetaData associated with a context Resource.

public class
ResourceCache.Miss

MetaData associated with a context Resource.

Field Summary

Modifier and TypeField and Description
protected transient Map<K, V>
protected transient int
protected transient int
protected transient ResourceCache.Content
private int
private int
private int
private MimeTypes
protected transient ResourceCache.Content
Inherited from org.mortbay.component.AbstractLifeCycle:
_listeners

Constructor Summary

AccessConstructor and Description
public
ResourceCache(MimeTypes mimeTypes)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
public void
protected void
public void
public int
public int
public int

Returns:

Returns the maxCachedFiles.
getMaxCachedFiles
()

public int
public int
private ResourceCache.Content
load(String pathInContext, Resource resource)

public ResourceCache.Content

Returns:

The entry matching pathInContext, or a new entry if no matching entry was found
lookup
(String
The key into the cache
pathInContext
,
ResourceFactory
If no matching entry is found, this ResourceFactory will be used to create the Resource for the new enry that is created.
factory
)

Get a Entry from the cache.

public ResourceCache.Content
lookup(String pathInContext, Resource resource)

public void
miss(String pathInContext, Resource resource)

Remember a Resource Miss!

public void
setMaxCachedFiles(int
The maxCachedFiles to set.
maxCachedFiles
)

public void
setMaxCachedFileSize(int maxCachedFileSize)

public void
setMaxCacheSize(int maxCacheSize)

Inherited from org.mortbay.component.AbstractLifeCycle:
addLifeCycleListenerisFailedisRunningisStartedisStartingisStoppedisStoppingremoveLifeCycleListenerstartstop

Field Detail

_cacheback to summary
protected transient Map<K, V> _cache
_cachedFilesback to summary
protected transient int _cachedFiles
_cachedSizeback to summary
protected transient int _cachedSize
_leastRecentlyUsedback to summary
protected transient ResourceCache.Content _leastRecentlyUsed
_maxCachedFilesback to summary
private int _maxCachedFiles
_maxCachedFileSizeback to summary
private int _maxCachedFileSize
_maxCacheSizeback to summary
private int _maxCacheSize
_mimeTypesback to summary
private MimeTypes _mimeTypes
_mostRecentlyUsedback to summary
protected transient ResourceCache.Content _mostRecentlyUsed

Constructor Detail

ResourceCacheback to summary
public ResourceCache(MimeTypes mimeTypes)

Constructor.

Method Detail

doStartback to summary
public synchronized void doStart() throws Exception

Overrides org.mortbay.component.AbstractLifeCycle.doStart.

doStopback to summary
public void doStop() throws InterruptedException

Overrides org.mortbay.component.AbstractLifeCycle.doStop.

Stop the context.

fillback to summary
protected void fill(ResourceCache.Content content) throws IOException
flushCacheback to summary
public void flushCache()
getCachedFilesback to summary
public int getCachedFiles()
getCachedSizeback to summary
public int getCachedSize()
getMaxCachedFilesback to summary
public int getMaxCachedFiles()
Returns:int

Returns the maxCachedFiles.

getMaxCachedFileSizeback to summary
public int getMaxCachedFileSize()
getMaxCacheSizeback to summary
public int getMaxCacheSize()
loadback to summary
private ResourceCache.Content load(String pathInContext, Resource resource) throws IOException
lookupback to summary
public ResourceCache.Content lookup(String pathInContext, ResourceFactory factory) throws IOException

Get a Entry from the cache. Get either a valid entry object or create a new one if possible.

Parameters
pathInContext:String

The key into the cache

factory:ResourceFactory

If no matching entry is found, this ResourceFactory will be used to create the Resource for the new enry that is created.

Returns:ResourceCache.Content

The entry matching pathInContext, or a new entry if no matching entry was found

lookupback to summary
public ResourceCache.Content lookup(String pathInContext, Resource resource) throws IOException
missback to summary
public void miss(String pathInContext, Resource resource) throws IOException

Remember a Resource Miss!

setMaxCachedFilesback to summary
public void setMaxCachedFiles(int maxCachedFiles)
Parameters
maxCachedFiles:int

The maxCachedFiles to set.

setMaxCachedFileSizeback to summary
public void setMaxCachedFileSize(int maxCachedFileSize)
setMaxCacheSizeback to summary
public void setMaxCacheSize(int maxCacheSize)
org.mortbay.jetty back to summary

public Class ResourceCache.Content

extends Object
implements HttpContent
Class Inheritance
All Implemented Interfaces
org.mortbay.jetty.HttpContent
Known Direct Subclasses
org.mortbay.jetty.ResourceCache.Miss

MetaData associated with a context Resource.

Field Summary

Modifier and TypeField and Description
pack-priv Buffer
pack-priv Buffer
pack-priv String
pack-priv long
pack-priv Buffer
pack-priv boolean
pack-priv ResourceCache.Content
pack-priv ResourceCache.Content
pack-priv Resource

Constructor Summary

AccessConstructor and Description
pack-priv
Content(Resource resource)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
cache(String pathInContext)

public Buffer
public long
public Buffer
public InputStream
public String
public Buffer
public Resource
public void
public boolean
public boolean

Returns:

true if the content is locked in the cache
isLocked
()

pack-priv boolean
public void
public void
setBuffer(Buffer buffer)

public void
public void
setLocked(boolean
true if the content is locked in the cache
locked
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bufferback to summary
pack-priv Buffer _buffer
_contentTypeback to summary
pack-priv Buffer _contentType
_keyback to summary
pack-priv String _key
_lastModifiedback to summary
pack-priv long _lastModified
_lastModifiedBytesback to summary
pack-priv Buffer _lastModifiedBytes
_lockedback to summary
pack-priv boolean _locked
_nextback to summary
pack-priv ResourceCache.Content _next
_prevback to summary
pack-priv ResourceCache.Content _prev
_resourceback to summary
pack-priv Resource _resource

Constructor Detail

Contentback to summary
pack-priv Content(Resource resource)

Method Detail

cacheback to summary
pack-priv void cache(String pathInContext)
getBufferback to summary
public Buffer getBuffer()

Implements org.mortbay.jetty.HttpContent.getBuffer.

getContentLengthback to summary
public long getContentLength()

Implements org.mortbay.jetty.HttpContent.getContentLength.

getContentTypeback to summary
public Buffer getContentType()

Implements org.mortbay.jetty.HttpContent.getContentType.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements org.mortbay.jetty.HttpContent.getInputStream.

getKeyback to summary
public String getKey()
getLastModifiedback to summary
public Buffer getLastModified()

Implements org.mortbay.jetty.HttpContent.getLastModified.

getResourceback to summary
public Resource getResource()

Implements org.mortbay.jetty.HttpContent.getResource.

invalidateback to summary
public void invalidate()
isCachedback to summary
public boolean isCached()
isLockedback to summary
public boolean isLocked()
Returns:boolean

true if the content is locked in the cache

isValidback to summary
pack-priv boolean isValid()
releaseback to summary
public void release()

Implements org.mortbay.jetty.HttpContent.release.

setBufferback to summary
public void setBuffer(Buffer buffer)
setContentTypeback to summary
public void setContentType(Buffer type)
setLockedback to summary
public void setLocked(boolean locked)
Parameters
locked:boolean

true if the content is locked in the cache

org.mortbay.jetty back to summary

public Class ResourceCache.Miss

extends Content
Class Inheritance

MetaData associated with a context Resource.

Field Summary

Inherited from org.mortbay.jetty.ResourceCache.Content:
_buffer_contentType_key_lastModified_lastModifiedBytes_locked_next_prev_resource

Constructor Summary

AccessConstructor and Description
pack-priv
Miss(Resource resource)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
Inherited from org.mortbay.jetty.ResourceCache.Content:
cachegetBuffergetContentLengthgetContentTypegetInputStreamgetKeygetLastModifiedgetResourceinvalidateisCachedisLockedreleasesetBuffersetContentTypesetLocked

Constructor Detail

Missback to summary
pack-priv Miss(Resource resource)

Method Detail

isValidback to summary
pack-priv boolean isValid()

Overrides org.mortbay.jetty.ResourceCache.Content.isValid.