Package org.eclipse.jetty.server
Class CachedContentFactory
- java.lang.Object
-
- org.eclipse.jetty.server.CachedContentFactory
-
- All Implemented Interfaces:
org.eclipse.jetty.http.HttpContent.ContentFactory
public class CachedContentFactory extends Object implements org.eclipse.jetty.http.HttpContent.ContentFactory
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCachedContentFactory.CachedHttpContentMetaData associated with a context Resource.classCachedContentFactory.CachedPrecompressedHttpContent
-
Constructor Summary
Constructors Constructor Description CachedContentFactory(CachedContentFactory parent, org.eclipse.jetty.util.resource.ResourceFactory factory, org.eclipse.jetty.http.MimeTypes mimeTypes, boolean useFileMappedBuffer, boolean etags, org.eclipse.jetty.http.CompressedContentFormat[] precompressedFormats)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidflushCache()intgetCachedFiles()intgetCachedSize()org.eclipse.jetty.http.HttpContentgetContent(String pathInContext, int maxBufferSize)Returns an entry from the cache, or creates a new one.protected ByteBuffergetDirectBuffer(org.eclipse.jetty.util.resource.Resource resource)protected ByteBuffergetIndirectBuffer(org.eclipse.jetty.util.resource.Resource resource)protected ByteBuffergetMappedBuffer(org.eclipse.jetty.util.resource.Resource resource)intgetMaxCachedFiles()intgetMaxCachedFileSize()intgetMaxCacheSize()protected booleanisCacheable(org.eclipse.jetty.util.resource.Resource resource)booleanisUseFileMappedBuffer()org.eclipse.jetty.http.HttpContentlookup(String pathInContext)Deprecated.voidsetMaxCachedFiles(int maxCachedFiles)voidsetMaxCachedFileSize(int maxCachedFileSize)voidsetMaxCacheSize(int maxCacheSize)StringtoString()
-
-
-
Constructor Detail
-
CachedContentFactory
public CachedContentFactory(CachedContentFactory parent, org.eclipse.jetty.util.resource.ResourceFactory factory, org.eclipse.jetty.http.MimeTypes mimeTypes, boolean useFileMappedBuffer, boolean etags, org.eclipse.jetty.http.CompressedContentFormat[] precompressedFormats)
Constructor.- Parameters:
parent- the parent resource cachefactory- the resource factorymimeTypes- Mimetype to use for meta datauseFileMappedBuffer- true to file memory mapped buffersetags- true to support etagsprecompressedFormats- array of precompression formats to support
-
-
Method Detail
-
getCachedSize
public int getCachedSize()
-
getCachedFiles
public int getCachedFiles()
-
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:
- the max number of cached files.
-
setMaxCachedFiles
public void setMaxCachedFiles(int maxCachedFiles)
- Parameters:
maxCachedFiles- the max number of cached files.
-
isUseFileMappedBuffer
public boolean isUseFileMappedBuffer()
-
flushCache
public void flushCache()
-
lookup
@Deprecated public org.eclipse.jetty.http.HttpContent lookup(String pathInContext) throws IOException
Deprecated.- Throws:
IOException
-
getContent
public org.eclipse.jetty.http.HttpContent getContent(String pathInContext, int maxBufferSize) throws IOException
Returns an entry from the cache, or creates a new one.
- Specified by:
getContentin interfaceorg.eclipse.jetty.http.HttpContent.ContentFactory- Parameters:
pathInContext- The key into the cachemaxBufferSize- The maximum buffer size allocated for this request. For cached content, a larger buffer may have previously been allocated and returned by theHttpContent.getDirectBuffer()orHttpContent.getIndirectBuffer()calls.- Returns:
- The entry matching
pathInContext, or a new entry if no matching entry was found. If the content exists but is not cacheable, then aResourceHttpContentinstance is returned. If the resource does not exist, then null is returned. - Throws:
IOException- if the resource cannot be retrieved
-
isCacheable
protected boolean isCacheable(org.eclipse.jetty.util.resource.Resource resource)
- Parameters:
resource- the resource to test- Returns:
- whether the resource is cacheable. The default implementation tests the cache sizes.
-
getIndirectBuffer
protected ByteBuffer getIndirectBuffer(org.eclipse.jetty.util.resource.Resource resource)
-
getMappedBuffer
protected ByteBuffer getMappedBuffer(org.eclipse.jetty.util.resource.Resource resource)
-
getDirectBuffer
protected ByteBuffer getDirectBuffer(org.eclipse.jetty.util.resource.Resource resource)
-
-