|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.w3c.tools.resources.AttributeHolder | +--org.w3c.tools.resources.Resource | +--org.w3c.www.protocol.http.cache.CachedResource
Field Summary | |
protected static int |
ATTR_CACHE_FILTER
Attribute index - The cache filter that manages us. |
protected static int |
ATTR_CONTENT_LENGTH
Attribute index - The resource content length. |
protected static int |
ATTR_CONTENT_TYPE
Attribute index - The resource content type. |
protected static int |
ATTR_DATE
Attribute index - The date at which the reply was emited. |
protected static int |
ATTR_ETAG
Attribute index - The entity tag (if any) associated with the resource. |
protected static int |
ATTR_EXTRA_HEADERS
Attribute index - The extension headers attribute. |
protected static int |
ATTR_FILE
Attribute index - The path of the file that has the resource content. |
protected static int |
ATTR_GENERATION
Attribute index - This cached resource generation. |
protected static int |
ATTR_INITAGE
Attribute index - The initial age of this resource. |
protected static int |
ATTR_LAST_MODIFIED
Attribute index - The last modified date of the cached content |
protected static int |
ATTR_MAXAGE
Attribute index - The resource's max age. |
protected static int |
ATTR_RESOURCE_STORE
Attribute index - The resource store associated with this resource. |
protected static int |
ATTR_RESPONSE_TIME
Attribute index - The response time of the cached response. |
protected static int |
ATTR_REVALIDATE
Attribute index - Does this cached resource should revalidate. |
protected static int |
ATTR_STATUS
Attribute index - The reply status. |
static int |
COND_FAILED
Condition check return code - Condition existed but failed. |
static int |
COND_OK
Condition check return code - Condition existed and succeeded. |
protected static long |
DEFAULT_MAXAGE
The default maxage, set to less then 24 hours, as specified in HTTP/1.1 |
Fields inherited from class org.w3c.tools.resources.Resource |
ATTR_CONTEXT,
ATTR_HELP_URL,
ATTR_IDENTIFIER,
ATTR_LAST_MODIFIED,
ATTR_PARENT,
ATTR_RESOURCE_FRAMES,
ATTR_STORE_ENTRY,
ATTR_URL |
Fields inherited from class org.w3c.tools.resources.AttributeHolder |
attributes,
slowpickle,
values |
Constructor Summary | |
CachedResource()
|
Method Summary | |
java.io.InputStream |
cacheContent(java.io.InputStream in)
Cache this content, then return the corresponding stream. |
int |
checkIfMatch(Request request)
Try to validate an If-Match request. |
int |
checkIfModifiedSince(Request request)
Try to validate an If-Modified-Since request. |
int |
checkIfNoneMatch(Request request)
Try to validate an If-None-Match request. |
int |
checkIfUnmodifiedSince(Request request)
Try to validate an If-Unmodified-Since request. |
protected void |
cleanUpload()
Mark that resource as now being loaded. |
protected long |
computeCurrentAge()
Compute this cached entry's current age. |
void |
delete()
Delete this cached entry from the cache. |
int |
getContentLength()
Get this cached entry content length. |
MimeType |
getContentType()
Get the content type associated to that cache entry. |
long |
getDate()
Get the HTTP date of the reply used to created that entry. |
java.lang.String |
getETag()
Get the entity tag associated with that cached entry. |
ArrayDictionary |
getExtraHeaders()
Get the extra headers stored for that resource. |
java.io.File |
getFile()
Get the file in which that resource's content is saved. |
int |
getGeneration()
Get the generation of that cached entry. |
HttpEntityTag |
getHETag()
Get the entity tag associated with that cached entry |
long |
getInitialAge()
Get this cached entry initial age. |
java.io.InputStream |
getInputStream()
Get the cached data for that cached entry. |
long |
getLastModified()
Get the last modified time of that entry. |
long |
getMaxAge()
Get this resource's max age. |
ResourceStore |
getResourceStore()
Get the store associated with this resource. |
long |
getResponseTime()
Get the time of the response used to cached that entry. |
boolean |
getRevalidate()
Should this cache entry always be revalidated ? |
int |
getStatus()
Get the HTTP status of that cached entry. |
Reply |
handleRangeRequest(Request request,
HttpRange r)
|
void |
initialize(CacheFilter filter,
Request request,
Reply reply)
|
void |
initialize(java.lang.Object[] values)
|
boolean |
isShared()
|
boolean |
isValid(Request request)
Is the currently cached version usable to answer the given request ? |
void |
notifyTeeFailure()
|
void |
notifyTeeSuccess(int size)
|
protected boolean |
notifyUploading(int upoldsize,
int upnewsize)
Is this resource already being loaded from the net. |
Reply |
perform(Request request)
This cached entry has been checked valid, perform given request. |
void |
setContentLength(int length)
Set the content length of that cached entry. |
void |
setContentType(MimeType type)
Set this cached entry content-type. |
void |
setDate(long date)
Set the HTTP date of the reply used to create or update that entry. |
protected void |
setDefaultMaxAge()
Compute a reasonable default value for the max-age of this resource. |
void |
setETag(java.lang.String etag)
Associate an entity tag with that cached enrty. |
void |
setExtraHeaders(ArrayDictionary a)
Set a new set of extra headers for that resource. |
void |
setFile(java.io.File file)
Set the file to which that resource's content should be saved into. |
void |
setGeneration(int generation)
Set the generation number of that resource. |
void |
setInitialAge(long initage)
Set this resource's initial age. |
void |
setLastModified(long lastmodified)
Set the last modified time of that cached entry. |
void |
setMaxAge(long maxage)
Set this cached entry max age. |
void |
setReplyHeaders(Reply reply)
Dump all our knowledge about this cached resource into the reply. |
void |
setRequestValidation(Request request)
Update an original request for a revalidation. |
void |
setResourceHeaders(Request request,
Reply reply)
Cache all the headers that can be cached after the given transaction. |
void |
setResponseTime(long responsetime)
Set this cached entry response time. |
void |
setRevalidate(boolean onoff)
Set the revalidation flag for that cached entry. |
void |
setStatus(int status)
Set the reply status for that entry. |
void |
setValue(int idx,
java.lang.Object value)
|
java.io.InputStream |
tryActiveCacheContent(java.io.InputStream in)
Try using an active stream to cache the content. |
void |
updateAges(Request request,
Reply reply)
Update this entry's age according to the given HTTP transaction. |
Reply |
validate(Request request,
Reply reply)
Given an HTTP transaction, validate that cached entry. |
protected void |
waitUpload()
Wait for the upload to finish, if needed. |
Methods inherited from class org.w3c.tools.resources.Resource |
acceptUnload,
checkMultipleLock,
collectFrames,
getClone,
getContext,
getFrame,
getFrames,
getHelpURL,
getHelpURL,
getIdentifier,
getParent,
getResourceReference,
getServer,
getSpace,
getSpaceEntry,
getStoreEntry,
getURLPath,
getValue,
getValue,
isInitialized,
markModified,
notifyUnload,
registerFrame,
setContext,
setContext,
setValue,
unregisterFrame,
updateAttributes |
Methods inherited from class org.w3c.tools.resources.AttributeHolder |
definesAttribute,
definesAttribute,
getAttributes,
getBoolean,
getChar,
getClone,
getClone,
getDouble,
getFloat,
getInt,
getLong,
getString,
getValue,
initialize,
lookupAttribute,
pickle,
print,
setBoolean,
setChar,
setDouble,
setFloat,
setInt,
setLong,
setString,
setValue,
unpickle,
unpickle,
unpickle,
unpickleInstance,
unpickleInstance |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int COND_FAILED
public static final int COND_OK
protected static long DEFAULT_MAXAGE
protected static int ATTR_FILE
protected static int ATTR_CONTENT_TYPE
protected static int ATTR_CONTENT_LENGTH
protected static int ATTR_MAXAGE
protected static int ATTR_INITAGE
protected static int ATTR_RESPONSE_TIME
protected static int ATTR_LAST_MODIFIED
protected static int ATTR_REVALIDATE
protected static int ATTR_CACHE_FILTER
protected static int ATTR_DATE
protected static int ATTR_STATUS
protected static int ATTR_ETAG
protected static int ATTR_GENERATION
protected static int ATTR_EXTRA_HEADERS
protected static int ATTR_RESOURCE_STORE
Constructor Detail |
public CachedResource()
Method Detail |
public ResourceStore getResourceStore()
public void setValue(int idx, java.lang.Object value)
public boolean isShared()
protected void setDefaultMaxAge()
This method computes and sets the default max age for this resource, it should be called as a last resort only.
public java.io.File getFile()
public void setFile(java.io.File file)
file
- The file to use.public MimeType getContentType()
public void setContentType(MimeType type)
type
- The new content type for that entry.public int getContentLength()
public void setContentLength(int length)
length
- The new content length of that entry.public long getMaxAge()
public void setMaxAge(long maxage)
maxage
- A number of milliseconds during which the entry will
remain valid, or -1 to undefine previous setting.public long getInitialAge()
public void setInitialAge(long initage)
initage
- The initial age as a number of milliseconds since Java
epoch, or -1 to undefine previous setting.public long getResponseTime()
public void setResponseTime(long responsetime)
responsetime
- A long number of milliseconds indicating the
response time relative to Java epoch, or -1 to
undefined previous setting.public long getLastModified()
Last-Modified
HTTP header.public void setLastModified(long lastmodified)
lastmodified
- The last modification date as a number of
milliseconds since Java epoch, or -1 to undefine
previous setting.public boolean getRevalidate()
public void setRevalidate(boolean onoff)
A
- boolean.public long getDate()
public void setDate(long date)
date
- The HTTP date encoded as a number of milliseconds since
Java epoch, or -1 to undefine previous setting.public int getStatus()
public void setStatus(int status)
status
- The HTTP status code of that entry, or -1
to undefine the previous setting.public java.lang.String getETag()
public HttpEntityTag getHETag()
public void setETag(java.lang.String etag)
etag
- The entity tag of the entry, or null
to reset the value.public int getGeneration()
public void setGeneration(int generation)
generation
- The new generation number of that resource.public ArrayDictionary getExtraHeaders()
public void setExtraHeaders(ArrayDictionary a)
headers
- The new set of headers.public java.io.InputStream getInputStream() throws java.io.IOException
public void notifyTeeFailure()
public void notifyTeeSuccess(int size)
public java.io.InputStream tryActiveCacheContent(java.io.InputStream in) throws java.io.IOException
public java.io.InputStream cacheContent(java.io.InputStream in) throws java.io.IOException
tryActiveCacheContent
. At the end of the method, the
cache filter is notified of byte size usage.public void setResourceHeaders(Request request, Reply reply)
request
- The request that triggered the reply.reply
- The origin server's reply.public void setReplyHeaders(Reply reply)
reply
- The reply we are building.public void setRequestValidation(Request request)
request
- The request to update.protected void cleanUpload()
protected final boolean notifyUploading(int upoldsize, int upnewsize)
cleanUpload
method gets called latter on.upoldsize
- The old size of cache entry (if available)upnewsize
- The expected size of the entry.protected final void waitUpload()
public Reply validate(Request request, Reply reply) throws java.io.IOException
request
- The request that we used to validate.reply
- The origin's server reply.public int checkIfModifiedSince(Request request)
If-Modified-Since
request.request
- The request to validate.COND_FAILED
, if the condition was
checked, but failed; COND_OK
of condition was checked
and succeeded, 0 otherwise.public int checkIfUnmodifiedSince(Request request)
If-Unmodified-Since
request.request
- The request to validate.COND_FAILED
, if the condition was
checked, but failed; COND_OK
of condition was checked
and succeeded, 0 otherwise.public int checkIfMatch(Request request)
If-Match
request.request
- The request to validate.COND_FAILED
, if the condition was
checked, but failed; COND_OK
of condition was checked
and succeeded, 0 otherwise.public int checkIfNoneMatch(Request request)
If-None-Match
request.request
- The request to validate.COND_FAILED
, if the condition was
checked, but failed; COND_OK
of condition was checked
and succeeded, 0 otherwise.public boolean isValid(Request request)
perform
method,
false otherwise (the resource needs to be refreshed).public Reply handleRangeRequest(Request request, HttpRange r)
public Reply perform(Request request) throws HttpException
request
- The request to perform.public void delete()
protected long computeCurrentAge()
public void updateAges(Request request, Reply reply)
request
- Our original request.reply
- The corresponding reply.public void initialize(CacheFilter filter, Request request, Reply reply) throws java.io.IOException
public void initialize(java.lang.Object[] values)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |