Class CachedContentFactory

    • Constructor Detail

      • CachedContentFactory

        public CachedContentFactory​(CachedContentFactory parent,
                                    ResourceFactory factory,
                                    MimeTypes mimeTypes,
                                    boolean useFileMappedBuffer,
                                    boolean etags,
                                    CompressedContentFormat[] precompressedFormats)
        Constructor.
        Parameters:
        parent - the parent resource cache
        factory - the resource factory
        mimeTypes - Mimetype to use for meta data
        useFileMappedBuffer - true to file memory mapped buffers
        etags - true to support etags
        precompressedFormats - 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 HttpContent lookup​(java.lang.String pathInContext)
                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • getContent

        public HttpContent getContent​(java.lang.String pathInContext,
                                      int maxBufferSize)
                               throws java.io.IOException

        Returns an entry from the cache, or creates a new one.

        Specified by:
        getContent in interface HttpContent.ContentFactory
        Parameters:
        pathInContext - The key into the cache
        maxBufferSize - The maximum buffer size 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.
        Returns:
        The entry matching pathInContext, or a new entry if no matching entry was found. If the content exists but is not cacheable, then a ResourceHttpContent instance is returned. If the resource does not exist, then null is returned.
        Throws:
        java.io.IOException - if the resource cannot be retrieved
      • isCacheable

        protected boolean isCacheable​(Resource resource)
        Parameters:
        resource - the resource to test
        Returns:
        whether the resource is cacheable. The default implementation tests the cache sizes.
      • getIndirectBuffer

        protected java.nio.ByteBuffer getIndirectBuffer​(Resource resource)
      • getMappedBuffer

        protected java.nio.ByteBuffer getMappedBuffer​(Resource resource)
      • getDirectBuffer

        protected java.nio.ByteBuffer getDirectBuffer​(Resource resource)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object