java.lang.Object | |
↳ | java.net.ResponseCache |
This class is an implementation of URLConnection
caches intended
primarily for the according stream handler implementations.
The system's default cache can be registered by invoking the method setDefault(ResponseCache)
and be retrieved by invoking the method getDefault()
. If URLConnection#useCaches
is set, URLConnection
class will use ResponseCache
to store and get
resources.
Whether the resource is cached depends on the implementation of ResponseCache
. If so, a CacheResponse
is returned from which the
stream handler reads. If the stream handler fails to get a resource from the
cache, it must get the resource from its original location.
To write to the cache, the protocol handlers call put()
, upon which a
CacheRequest
is supplied to which the resources are written.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new instance of this class.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the cached response according to the requesting URI, method and
headers.
| |||||||||||
Gets the default response cache of the system.
| |||||||||||
Allows the protocol handler to cache data after retrieving resources.
| |||||||||||
Sets the default response cache of the system.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Gets the cached response according to the requesting URI, method and headers.
uri | the requesting URI. |
---|---|
rqstMethod | the requesting method. |
rqstHeaders | a map of requesting headers. |
CacheResponse
object if the request is available in the cache
or null
otherwise.IOException | if an I/O error occurs while getting the cached data. |
---|---|
IllegalArgumentException | if any one of the parameters is set to null .
|
Gets the default response cache of the system.
ResponseCache
.SecurityException | if a security manager is installed but it doesn't have the
NetPermission("getResponseCache") .
|
---|
Allows the protocol handler to cache data after retrieving resources. The
ResponseCache
decides whether the resource data should be cached
or not. If so, this method returns a CacheRequest
with a WriteableByteChannel
to put the resource data down. Otherwise, this
method returns null
.
uri | the reference to the requested resource. |
---|---|
conn | the connection to fetch the response. |
null
otherwise.IOException | if an I/O error occurs while adding the resource. |
---|---|
IllegalArgumentException | if any one of the parameters is set to null .
|
Sets the default response cache of the system. Removes the system's
default ResponseCache
if the parameter responseCache
is
set to null
. This setting may be ignored by some non-standard
protocols.
responseCache | the ResponseCache instance to set as default or
null to remove the current default ResponseCache . |
---|
SecurityException | if a security manager is installed but it doesn't have the
NetPermission("setResponseCache") .
|
---|