Package org.apache.hc.client5.http.cache
Interface ResourceFactory
-
- All Known Implementing Classes:
FileResourceFactory
,HeapResourceFactory
@Contract(threading=STATELESS) public interface ResourceFactory
GeneratesResource
instances for handling cached HTTP response bodies.- Since:
- 4.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Resource
copy(java.lang.String requestId, Resource resource)
Clones an existingResource
.Resource
generate(java.lang.String requestId, byte[] content)
Creates aResource
from a given response body.Resource
generate(java.lang.String requestId, byte[] content, int off, int len)
Creates aResource
from a given response body.
-
-
-
Method Detail
-
generate
Resource generate(java.lang.String requestId, byte[] content) throws ResourceIOException
Creates aResource
from a given response body.- 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
-
generate
Resource generate(java.lang.String requestId, byte[] content, int off, int len) throws ResourceIOException
Creates aResource
from a given response body.- 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
-
copy
Resource copy(java.lang.String requestId, Resource resource) throws ResourceIOException
Clones an existingResource
.- Parameters:
requestId
- unique identifier provided to associate with the cloned response body.resource
- the original response body to clone.- Returns:
- the
Resource
copy - Throws:
ResourceIOException
-
-