Class FileResourceFactory

  • All Implemented Interfaces:
    ResourceFactory

    @Contract(threading=STATELESS)
    public class FileResourceFactory
    extends java.lang.Object
    implements ResourceFactory
    Generates Resource instances whose body is stored in a temporary file.
    Since:
    4.1
    • Field Detail

      • cacheDir

        private final java.io.File cacheDir
    • Constructor Detail

      • FileResourceFactory

        public FileResourceFactory​(java.io.File cacheDir)
    • Method Detail

      • generateUniqueCacheFile

        private java.io.File generateUniqueCacheFile​(java.lang.String requestId)
      • generate

        public Resource generate​(java.lang.String requestId,
                                 byte[] content,
                                 int off,
                                 int len)
                          throws ResourceIOException
        Description copied from interface: ResourceFactory
        Creates a Resource from a given response body.
        Specified by:
        generate in interface ResourceFactory
        Parameters:
        requestId - a unique identifier for this particular response body.
        content - byte array that represents the origin HTTP response body.
        off - the start offset in the array.
        len - the number of bytes to read from the array.
        Returns:
        a Resource containing however much of the response body was successfully read.
        Throws:
        ResourceIOException
      • generate

        public Resource generate​(java.lang.String requestId,
                                 byte[] content)
                          throws ResourceIOException
        Description copied from interface: ResourceFactory
        Creates a Resource from a given response body.
        Specified by:
        generate in interface ResourceFactory
        Parameters:
        requestId - a unique identifier for this particular response body.
        content - byte array that represents the origin HTTP response body.
        Returns:
        a Resource containing however much of the response body was successfully read.
        Throws:
        ResourceIOException