public class CachedContentFactory extends java.lang.Object implements HttpContent.ContentFactory
Modifier and Type | Class and Description |
---|---|
class |
CachedContentFactory.CachedHttpContent
MetaData associated with a context Resource.
|
class |
CachedContentFactory.CachedPrecompressedHttpContent |
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<java.lang.String,CachedContentFactory.CachedHttpContent> |
_cache |
private java.util.concurrent.atomic.AtomicInteger |
_cachedFiles |
private java.util.concurrent.atomic.AtomicInteger |
_cachedSize |
private boolean |
_etags |
private ResourceFactory |
_factory |
private int |
_maxCachedFiles |
private int |
_maxCachedFileSize |
private int |
_maxCacheSize |
private MimeTypes |
_mimeTypes |
private CachedContentFactory |
_parent |
private CompressedContentFormat[] |
_precompressedFormats |
private boolean |
_useFileMappedBuffer |
private static Logger |
LOG |
private static java.util.Map<CompressedContentFormat,CachedContentFactory.CachedPrecompressedHttpContent> |
NO_PRECOMPRESSED |
Constructor and Description |
---|
CachedContentFactory(CachedContentFactory parent,
ResourceFactory factory,
MimeTypes mimeTypes,
boolean useFileMappedBuffer,
boolean etags,
CompressedContentFormat[] precompressedFormats)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
flushCache() |
int |
getCachedFiles() |
int |
getCachedSize() |
HttpContent |
getContent(java.lang.String pathInContext,
int maxBufferSize)
Get a Entry from the cache.
|
protected java.nio.ByteBuffer |
getDirectBuffer(Resource resource) |
protected java.nio.ByteBuffer |
getIndirectBuffer(Resource resource) |
protected java.nio.ByteBuffer |
getMappedBuffer(Resource resource) |
int |
getMaxCachedFiles() |
int |
getMaxCachedFileSize() |
int |
getMaxCacheSize() |
protected boolean |
isCacheable(Resource resource) |
boolean |
isUseFileMappedBuffer() |
private HttpContent |
load(java.lang.String pathInContext,
Resource resource,
int maxBufferSize) |
HttpContent |
lookup(java.lang.String pathInContext)
Deprecated.
|
void |
setMaxCachedFiles(int maxCachedFiles) |
void |
setMaxCachedFileSize(int maxCachedFileSize) |
void |
setMaxCacheSize(int maxCacheSize) |
private void |
shrinkCache() |
java.lang.String |
toString() |
private static final Logger LOG
private static final java.util.Map<CompressedContentFormat,CachedContentFactory.CachedPrecompressedHttpContent> NO_PRECOMPRESSED
private final java.util.concurrent.ConcurrentMap<java.lang.String,CachedContentFactory.CachedHttpContent> _cache
private final java.util.concurrent.atomic.AtomicInteger _cachedSize
private final java.util.concurrent.atomic.AtomicInteger _cachedFiles
private final ResourceFactory _factory
private final CachedContentFactory _parent
private final MimeTypes _mimeTypes
private final boolean _etags
private final CompressedContentFormat[] _precompressedFormats
private final boolean _useFileMappedBuffer
private int _maxCachedFileSize
private int _maxCachedFiles
private int _maxCacheSize
public CachedContentFactory(CachedContentFactory parent, ResourceFactory factory, MimeTypes mimeTypes, boolean useFileMappedBuffer, boolean etags, CompressedContentFormat[] precompressedFormats)
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 supportpublic int getCachedSize()
public int getCachedFiles()
public int getMaxCachedFileSize()
public void setMaxCachedFileSize(int maxCachedFileSize)
public int getMaxCacheSize()
public void setMaxCacheSize(int maxCacheSize)
public int getMaxCachedFiles()
public void setMaxCachedFiles(int maxCachedFiles)
maxCachedFiles
- The maxCachedFiles to set.public boolean isUseFileMappedBuffer()
public void flushCache()
@Deprecated public HttpContent lookup(java.lang.String pathInContext) throws java.io.IOException
java.io.IOException
public HttpContent getContent(java.lang.String pathInContext, int maxBufferSize) throws java.io.IOException
getContent
in interface HttpContent.ContentFactory
pathInContext
- The key into the cachemaxBufferSize
- The maximum buffer to allocated for this request. For cached content, a larger buffer may have
previously been allocated and returned by the HttpContent.getDirectBuffer()
or HttpContent.getIndirectBuffer()
calls.pathInContext
, or a new entry
if no matching entry was found. If the content exists but is not cachable,
then a ResourceHttpContent
instance is return. If
the resource does not exist, then null is returned.java.io.IOException
- Problem loading the resourceprotected boolean isCacheable(Resource resource)
resource
- the resource to testprivate HttpContent load(java.lang.String pathInContext, Resource resource, int maxBufferSize) throws java.io.IOException
java.io.IOException
private void shrinkCache()
protected java.nio.ByteBuffer getIndirectBuffer(Resource resource)
protected java.nio.ByteBuffer getMappedBuffer(Resource resource)
protected java.nio.ByteBuffer getDirectBuffer(Resource resource)
public java.lang.String toString()
toString
in class java.lang.Object