| java.lang.Object java.net.ResponseCache
ResponseCache | abstract public class ResponseCache (Code) | | ResponseCache implements URLConnection caches. System default cache can be
registered by invoking ResponseCache.setDefault (ResponseCache),
and can be retrieved by invoking ResponseCache.getDefault .
If URLConnection#useCaches is set, URLConnection class will
use ResponseCache to store and get resources. Whether the
resource is cached depends on ResponseCache implementation. If
a request resource is cached, protocol handler will fecth it from the cache.
If the protocol handler fails to get resource from the cache, it turns to get
the resource from its original location.
|
Method Summary | |
abstract public CacheResponse | get(URI uri, String rqstMethod, Map<String, List<String>> rqstHeaders) Gets the cached response according to requesting uri,method and headers.
Parameters: uri - A URL represents requesting uri. Parameters: rqstMethod - A String represents requesting method. Parameters: rqstHeaders - A Map from request header field names to listsof field values represents requesting headers. | public static ResponseCache | getDefault() Gets system default response cache. | abstract public CacheRequest | put(URI uri, URLConnection conn) Protocol handler calls this method after retrieving resources. | public static void | setDefault(ResponseCache responseCache) Sets the system default response cache when responseCache is not null.
Otherwise, the method unsets the system default response cache. |
ResponseCache | public ResponseCache()(Code) | | Constructor method.
|
get | abstract public CacheResponse get(URI uri, String rqstMethod, Map<String, List<String>> rqstHeaders) throws IOException(Code) | | Gets the cached response according to requesting uri,method and headers.
Parameters: uri - A URL represents requesting uri. Parameters: rqstMethod - A String represents requesting method. Parameters: rqstHeaders - A Map from request header field names to listsof field values represents requesting headers. A CacheResponse object if the request is availablein the cache. Otherwise, this method returns null. throws: IOException - If an I/O error is encountered. throws: IllegalArgumentException - If any one of the parameters is null |
getDefault | public static ResponseCache getDefault()(Code) | | Gets system default response cache.
default ResponseCache . throws: SecurityException - If a security manager is installed and it doesn't haveNetPermission ("getResponseCache"). |
put | abstract public CacheRequest put(URI uri, URLConnection conn) throws IOException(Code) | | Protocol handler calls this method after retrieving resources. The
ResponseCache decides whether the resource should be
cached. If the resource needs to be cached, this method will return a
CacheRequest with a WriteableByteChannel ,
and then, protocol handler will use this channel to write the resource
data into the cache. Otherwise, if the resource doesn't need to be
cached, it returns null.
Parameters: uri - Parameters: conn - a CacheRequest which containsWriteableByteChannel if the resource is cached.Otherwise, it returns null. throws: IOException - If an I/O error is encountered. throws: IllegalArgumentException - If any one of the parameters is null. |
setDefault | public static void setDefault(ResponseCache responseCache)(Code) | | Sets the system default response cache when responseCache is not null.
Otherwise, the method unsets the system default response cache. This
setting may be ignored by some non-standard protocols.
Parameters: responseCache - Set default ResponseCache . If responseCache isnull, it unsets the cache. throws: SecurityException - If a security manager is installed and it doesn't haveNetPermission ("setResponseCache"). |
|
|