@Contract(threading=IMMUTABLE) public class HeapResourceFactory extends java.lang.Object implements ResourceFactory
Resource
instances stored entirely in heap.Constructor and Description |
---|
HeapResourceFactory() |
Modifier and Type | Method and Description |
---|---|
Resource |
copy(java.lang.String requestId,
Resource resource)
Clones an existing
Resource . |
(package private) Resource |
createResource(byte[] buf) |
Resource |
generate(java.lang.String requestId,
java.io.InputStream instream,
InputLimit limit)
Creates a
Resource from a given response body. |
public Resource generate(java.lang.String requestId, java.io.InputStream instream, InputLimit limit) throws java.io.IOException
ResourceFactory
Resource
from a given response body.generate
in interface ResourceFactory
requestId
- a unique identifier for this particular
response bodyinstream
- the original InputStream
containing the response body of the origin HTTP response.limit
- maximum number of bytes to consume of the
response body; if this limit is reached before the
response body is fully consumed, mark the limit has
having been reached and return a Resource
containing the data read to that point.Resource
containing however much of
the response body was successfully read.java.io.IOException
public Resource copy(java.lang.String requestId, Resource resource) throws java.io.IOException
ResourceFactory
Resource
.copy
in interface ResourceFactory
requestId
- unique identifier provided to associate
with the cloned response body.resource
- the original response body to clone.Resource
copyjava.io.IOException
Resource createResource(byte[] buf)