org.apache.http.impl.client.cache
Class CachingHttpClient

java.lang.Object
  extended by org.apache.http.impl.client.cache.CachingHttpClient
All Implemented Interfaces:
HttpClient

@ThreadSafe
public class CachingHttpClient
extends Object
implements HttpClient

Since:
4.1

Field Summary
static String CACHE_RESPONSE_STATUS
           
 
Constructor Summary
CachingHttpClient()
           
CachingHttpClient(CacheConfig config)
           
CachingHttpClient(HttpClient client)
           
CachingHttpClient(HttpClient client, CacheConfig config)
           
CachingHttpClient(HttpClient client, HttpCacheStorage storage, CacheConfig config)
           
CachingHttpClient(HttpClient client, ResourceFactory resourceFactory, HttpCacheStorage storage, CacheConfig config)
           
 
Method Summary
 org.apache.http.HttpResponse execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
          Execute an HttpRequest @ a given HttpHost
 org.apache.http.HttpResponse execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)
          Executes a request to the target using the given context.
<T> T
execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, ResponseHandler<? extends T> responseHandler)
          Execute an HttpRequest @ a given HttpHost with a specified ResponseHandler that will deal with the result of the call.
<T> T
execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, ResponseHandler<? extends T> responseHandler, org.apache.http.protocol.HttpContext context)
          Execute an HttpRequest @ a given HttpHost with a specified ResponseHandler that will deal with the result of the call using a specific HttpContext
 org.apache.http.HttpResponse execute(HttpUriRequest request)
          Executes a request using the default context.
 org.apache.http.HttpResponse execute(HttpUriRequest request, org.apache.http.protocol.HttpContext context)
          Executes a request using the given context.
<T> T
execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler)
          Executes a request using the default context and processes the response using the given response handler.
<T> T
execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, org.apache.http.protocol.HttpContext context)
          Executes a request using the given context and processes the response using the given response handler.
 long getCacheHits()
          Return the number of times that the cache successfully answered an HttpRequest for a document of information from the server.
 long getCacheMisses()
          Return the number of times that the cache was unable to answer an HttpRequest for a document of information from the server.
 long getCacheUpdates()
          Return the number of times that the cache was able to revalidate an existing cache entry for a document of information from the server.
 ClientConnectionManager getConnectionManager()
          Obtains the connection manager used by this client.
 org.apache.http.params.HttpParams getParams()
          Obtains the parameters for this client.
 boolean isSharedCache()
           
 boolean supportsRangeAndContentRangeHeaders()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_RESPONSE_STATUS

public static final String CACHE_RESPONSE_STATUS
See Also:
Constant Field Values
Constructor Detail

CachingHttpClient

public CachingHttpClient()

CachingHttpClient

public CachingHttpClient(CacheConfig config)

CachingHttpClient

public CachingHttpClient(HttpClient client)

CachingHttpClient

public CachingHttpClient(HttpClient client,
                         CacheConfig config)

CachingHttpClient

public CachingHttpClient(HttpClient client,
                         ResourceFactory resourceFactory,
                         HttpCacheStorage storage,
                         CacheConfig config)

CachingHttpClient

public CachingHttpClient(HttpClient client,
                         HttpCacheStorage storage,
                         CacheConfig config)
Method Detail

getCacheHits

public long getCacheHits()
Return the number of times that the cache successfully answered an HttpRequest for a document of information from the server.

Returns:
long the number of cache successes

getCacheMisses

public long getCacheMisses()
Return the number of times that the cache was unable to answer an HttpRequest for a document of information from the server.

Returns:
long the number of cache failures/misses

getCacheUpdates

public long getCacheUpdates()
Return the number of times that the cache was able to revalidate an existing cache entry for a document of information from the server.

Returns:
long the number of cache revalidations

execute

public org.apache.http.HttpResponse execute(org.apache.http.HttpHost target,
                                            org.apache.http.HttpRequest request)
                                     throws IOException
Execute an HttpRequest @ a given HttpHost

Specified by:
execute in interface HttpClient
Parameters:
target - the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
request - the request to execute
Returns:
HttpResponse The cached entry or the result of a backend call
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public <T> T execute(org.apache.http.HttpHost target,
                     org.apache.http.HttpRequest request,
                     ResponseHandler<? extends T> responseHandler)
          throws IOException
Execute an HttpRequest @ a given HttpHost with a specified ResponseHandler that will deal with the result of the call.

Specified by:
execute in interface HttpClient
Type Parameters:
T - The Return Type Identified by the generic type of the ResponseHandler
Parameters:
target - the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
request - the request to execute
responseHandler - the response handler
Returns:
T The response type as handled by ResponseHandler
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public <T> T execute(org.apache.http.HttpHost target,
                     org.apache.http.HttpRequest request,
                     ResponseHandler<? extends T> responseHandler,
                     org.apache.http.protocol.HttpContext context)
          throws IOException
Execute an HttpRequest @ a given HttpHost with a specified ResponseHandler that will deal with the result of the call using a specific HttpContext

Specified by:
execute in interface HttpClient
Type Parameters:
T - The Return Type Identified by the generic type of the ResponseHandler
Parameters:
target - the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
request - the request to execute
responseHandler - the response handler
context - the context to use for the execution, or null to use the default context
Returns:
T The response type as handled by ResponseHandler
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public org.apache.http.HttpResponse execute(HttpUriRequest request)
                                     throws IOException
Description copied from interface: HttpClient
Executes a request using the default context.

Specified by:
execute in interface HttpClient
Parameters:
request - the request to execute
Returns:
HttpResponse The cached entry or the result of a backend call
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public org.apache.http.HttpResponse execute(HttpUriRequest request,
                                            org.apache.http.protocol.HttpContext context)
                                     throws IOException
Description copied from interface: HttpClient
Executes a request using the given context. The route to the target will be determined by the HTTP client.

Specified by:
execute in interface HttpClient
Parameters:
request - the request to execute
context - the context to use for the execution, or null to use the default context
Returns:
HttpResponse The cached entry or the result of a backend call
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public <T> T execute(HttpUriRequest request,
                     ResponseHandler<? extends T> responseHandler)
          throws IOException
Description copied from interface: HttpClient
Executes a request using the default context and processes the response using the given response handler.

Specified by:
execute in interface HttpClient
Type Parameters:
T - The Return Type Identified by the generic type of the ResponseHandler
Parameters:
request - the request to execute
responseHandler - the response handler
Returns:
T The response type as handled by ResponseHandler
Throws:
IOException
ClientProtocolException - in case of an http protocol error

execute

public <T> T execute(HttpUriRequest request,
                     ResponseHandler<? extends T> responseHandler,
                     org.apache.http.protocol.HttpContext context)
          throws IOException
Description copied from interface: HttpClient
Executes a request using the given context and processes the response using the given response handler.

Specified by:
execute in interface HttpClient
Type Parameters:
T - The Return Type Identified by the generic type of the ResponseHandler
Parameters:
request - the request to execute
responseHandler - the response handler
context - the http context
Returns:
T The response type as handled by ResponseHandler
Throws:
IOException
ClientProtocolException - in case of an http protocol error

getConnectionManager

public ClientConnectionManager getConnectionManager()
Description copied from interface: HttpClient
Obtains the connection manager used by this client.

Specified by:
getConnectionManager in interface HttpClient
Returns:
the connection manager

getParams

public org.apache.http.params.HttpParams getParams()
Description copied from interface: HttpClient
Obtains the parameters for this client. These parameters will become defaults for all requests being executed with this client, and for the parameters of dependent objects in this client.

Specified by:
getParams in interface HttpClient
Returns:
the parameters

execute

public org.apache.http.HttpResponse execute(org.apache.http.HttpHost target,
                                            org.apache.http.HttpRequest request,
                                            org.apache.http.protocol.HttpContext context)
                                     throws IOException
Description copied from interface: HttpClient
Executes a request to the target using the given context.

Specified by:
execute in interface HttpClient
Parameters:
target - the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
request - the request to execute
context - the context to use for the execution, or null to use the default context
Returns:
the response
Throws:
IOException
ClientProtocolException - in case of an http protocol error

supportsRangeAndContentRangeHeaders

public boolean supportsRangeAndContentRangeHeaders()

isSharedCache

public boolean isSharedCache()


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.