@NotThreadSafe public class HttpResource extends AbstractResource
| Modifier and Type | Class and Description |
|---|---|
static interface |
HttpResource.HttpGetCustomizationStrategy
Strategy that can be used to customize an
HttpGet object before it is used. |
static interface |
HttpResource.HttpResponseCustomizationStrategy
Strategy used to perform any
HttpResponse processing prior to returning the InputStream for its
content. |
| Modifier and Type | Field and Description |
|---|---|
static String |
ETAG_PROP
Property name under which the ETag data is stored.
|
private HttpClient |
httpClient
Client used to make HTTP requests.
|
private HttpResource.HttpGetCustomizationStrategy |
httpGetCustomizationStrategy
Strategy used to customize an
HttpGet before using it. |
private HttpResource.HttpResponseCustomizationStrategy |
httpResponseCustomizationStrategy
Strategy used to customize an
HttpResponse before get its content. |
static String |
LAST_MODIFIED_PROP
Property name under which the Last-Modified data is stored.
|
private Logger |
log
Class logger.
|
| Constructor and Description |
|---|
HttpResource(HttpClient client,
String url)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private HttpGet |
buildGetMethod()
Gets the, potentially customized,
HttpGet method. |
protected void |
doDestroy()
Performs component specific destruction logic.
|
protected boolean |
doExists()
Checks whether the resource exists.
|
protected InputStream |
doGetInputStream()
Gets the input stream to the resource's data.
|
protected long |
doGetLastModifiedTime()
Gets the time, in milliseconds since the epoch, when the resource was last modified.
|
HttpResource.HttpGetCustomizationStrategy |
getHttpGetCustomizationStrategy()
Gets the strategy used customize the
HttpGet used to fetch the resource. |
HttpResource.HttpResponseCustomizationStrategy |
getHttpResponseCustomizationStrategy()
Gets the strategy used to customize the
HttpResponse before its content is returned. |
private org.apache.http.HttpResponse |
getResourceHeaders()
Attempts to fetch only the headers for a given resource.
|
void |
setHttpGetCustomizationStrategy(HttpResource.HttpGetCustomizationStrategy strategy)
Sets the strategy used customize the
HttpGet used to fetch the resource. |
void |
setHttpResponseCustomizationStrategy(HttpResource.HttpResponseCustomizationStrategy strategy)
Sets the strategy used to customize the
HttpResponse before its content is returned. |
doValidate, equals, exists, getInputStream, getLastModifiedTime, getLocation, hashCode, setLocation, toString, validatedestroy, doInitialize, initialize, isDestroyed, isInitializedclone, finalize, getClass, notify, notifyAll, wait, wait, waitdestroy, isDestroyedinitialize, isInitializedpublic static final String ETAG_PROP
public static final String LAST_MODIFIED_PROP
private final Logger log
private HttpClient httpClient
private HttpResource.HttpGetCustomizationStrategy httpGetCustomizationStrategy
HttpGet before using it.private HttpResource.HttpResponseCustomizationStrategy httpResponseCustomizationStrategy
HttpResponse before get its content.public HttpResource(@Nonnull HttpClient client, @Nonnull@NotEmpty String url)
client - client used to fetch the remote resource dataurl - URL of the remote resource data@Nullable public HttpResource.HttpGetCustomizationStrategy getHttpGetCustomizationStrategy()
HttpGet used to fetch the resource.HttpGet used to fetch the resourcepublic void setHttpGetCustomizationStrategy(@Nullable HttpResource.HttpGetCustomizationStrategy strategy)
HttpGet used to fetch the resource.strategy - strategy used customize the HttpGet used to fetch the resource@Nullable public HttpResource.HttpResponseCustomizationStrategy getHttpResponseCustomizationStrategy()
HttpResponse before its content is returned.HttpResponse before its content is returnedpublic void setHttpResponseCustomizationStrategy(@Nullable HttpResource.HttpResponseCustomizationStrategy strategy)
HttpResponse before its content is returned.strategy - strategy used to customize the HttpResponse before its content is returnedprotected long doGetLastModifiedTime()
throws ResourceException
doGetLastModifiedTime in class AbstractResourceResourceException - thrown if the last modified time can not be determinedprotected boolean doExists()
throws ResourceException
doExists in class AbstractResourceResourceException - thrown if there is a problem determining if the resource exists@Nonnull protected InputStream doGetInputStream() throws ResourceException
doGetInputStream in class AbstractResourceResourceException - thrown if an input stream can not be created for the resourceprotected void doDestroy()
doDestroy in class AbstractDestructableInitializableComponentprivate org.apache.http.HttpResponse getResourceHeaders()
throws ResourceException
ResourceException - thrown if there is a problem contacting the resourceCopyright © 1999-2013. All Rights Reserved.