FileDocCategorySizeDatePackage
HttpCacheEntry.javaAPI DocGlassfish v2 API4074Fri May 04 22:35:28 BST 2007com.sun.appserv.web.cache.filter

HttpCacheEntry

public class HttpCacheEntry extends Object
HttpCacheEntry Each entry holds cached (HTTP) response: a) response bytes b) response headers c) expiryTime d) parameterEncoding used e) entryKey this entry represents, to match the entry within the hash bucket. XXX: should implement methods to enable serialization of cached response?

Fields Summary
public static final int
VALUE_NOT_SET
int
statusCode
String
statusMessage
HashMap
responseHeaders
HashMap
dateHeaders
ArrayList
cookies
String
contentType
Locale
locale
int
contentLength
byte[]
bytes
int
timeout
volatile long
expireTime
Constructors Summary
Methods Summary
public voidclear()
clear the contents

        bytes = null;
        responseHeaders = null;
        cookies = null;
    
public voidcomputeExpireTime(int timeout)
compute when this entry to be expired based on timeout relative to current time.

param
timeout in seconds

        this.timeout = timeout;

        // timeout is relative to current time
        this.expireTime = (timeout == -1) ? timeout :
                          System.currentTimeMillis() + (timeout * 1000);
    
public intgetSize()
get the size

return
size of this entry in bytes Note: this is only approximate

        int size = 0;
        if (bytes != null) {
            size = bytes.length;
        }

        // size of response bytes plus headers (each approx 20 chars or 40 bytes)
        return (size + (40 * responseHeaders.size()) );
    
public booleanisValid()
is this response still valid?

        return (expireTime > System.currentTimeMillis() || expireTime == -1);
    
public voidsetExpireTime(long expireTime)
set the real expire time

param
expireTime in milli seconds


                   
        
        this.expireTime = expireTime;