Package org.eclipse.jetty.server
Class CachedContentFactory
java.lang.Object
org.eclipse.jetty.server.CachedContentFactory
- All Implemented Interfaces:
HttpContent.ContentFactory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
MetaData associated with a context Resource.class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<String, CachedContentFactory.CachedHttpContent> private final AtomicInteger
private final AtomicInteger
private final boolean
private final ResourceFactory
private int
private int
private int
private final MimeTypes
private final CachedContentFactory
private final CompressedContentFormat[]
private final boolean
private static final Logger
private static final Map
<CompressedContentFormat, CachedContentFactory.CachedPrecompressedHttpContent> -
Constructor Summary
ConstructorsConstructorDescriptionCachedContentFactory
(CachedContentFactory parent, ResourceFactory factory, MimeTypes mimeTypes, boolean useFileMappedBuffer, boolean etags, CompressedContentFormat[] precompressedFormats) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
int
getContent
(String pathInContext, int maxBufferSize) Returns an entry from the cache, or creates a new one.protected ByteBuffer
getDirectBuffer
(Resource resource) protected ByteBuffer
getIndirectBuffer
(Resource resource) protected ByteBuffer
getMappedBuffer
(Resource resource) int
int
int
protected boolean
isCacheable
(Resource resource) boolean
private HttpContent
Deprecated.void
setMaxCachedFiles
(int maxCachedFiles) void
setMaxCachedFileSize
(int maxCachedFileSize) void
setMaxCacheSize
(int maxCacheSize) private void
toString()
-
Field Details
-
LOG
-
NO_PRECOMPRESSED
private static final Map<CompressedContentFormat,CachedContentFactory.CachedPrecompressedHttpContent> NO_PRECOMPRESSED -
_cache
-
_cachedSize
-
_cachedFiles
-
_factory
-
_parent
-
_mimeTypes
-
_etags
private final boolean _etags -
_precompressedFormats
-
_useFileMappedBuffer
private final boolean _useFileMappedBuffer -
_maxCachedFileSize
private int _maxCachedFileSize -
_maxCachedFiles
private int _maxCachedFiles -
_maxCacheSize
private int _maxCacheSize
-
-
Constructor Details
-
CachedContentFactory
public CachedContentFactory(CachedContentFactory parent, ResourceFactory factory, MimeTypes mimeTypes, boolean useFileMappedBuffer, boolean etags, 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 Details
-
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.- Throws:
IOException
-
getContent
Returns an entry from the cache, or creates a new one.
- Specified by:
getContent
in interfaceHttpContent.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 aResourceHttpContent
instance is returned. If the resource does not exist, then null is returned. - Throws:
IOException
- if the resource cannot be retrieved
-
isCacheable
- Parameters:
resource
- the resource to test- Returns:
- whether the resource is cacheable. The default implementation tests the cache sizes.
-
load
-
shrinkCache
private void shrinkCache() -
getIndirectBuffer
-
getMappedBuffer
-
getDirectBuffer
-
toString
-