01: // SimplePushCacheValidator.java
02: // $Id: SimplePushCacheValidator.java,v 1.1 2001/10/03 15:00:46 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 2001.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.protocol.http.cache.push;
07:
08: import org.w3c.www.http.HTTP;
09: import org.w3c.www.protocol.http.Reply;
10: import org.w3c.www.protocol.http.Request;
11: import org.w3c.www.protocol.http.cache.SimpleCacheValidator;
12: import org.w3c.www.protocol.http.cache.CachedResource;
13:
14: import java.net.URL;
15:
16: /**
17: * SimpleCacheValidator with modified behaviour to avoid cleaning
18: * resources that have been pushed into the cache
19: *
20: * @author Paul Henshaw, The Fantastic Corporation, Paul.Henshaw@fantastic.com
21: * @version $Revision: 1.1 $
22: * $Id: SimplePushCacheValidator.java,v 1.1 2001/10/03 15:00:46 ylafon Exp $
23: */
24: public class SimplePushCacheValidator extends SimpleCacheValidator {
25:
26: /**
27: * Check if the request is stale or not
28: * @return false if resourse was pushed into cache,
29: * calls super.checkStaleness(cr) otherwise
30: */
31: public boolean checkStaleness(CachedResource cr) {
32: if (PushCacheManager.instance().isPushResource(cr)) {
33: return (false);
34: }
35: return (super .checkStaleness(cr));
36: }
37:
38: /**
39: * reset all the ages after a revalidation
40: * @param cr, the CachedResource we are upgrading.
41: * @param request, the Request
42: * @param reply, the Reply
43: */
44: public void revalidateResource(CachedResource cr, Request request,
45: Reply reply) {
46:
47: if (PushCacheManager.instance().isPushResource(cr)
48: || reply.getStatus() == HTTP.NOT_MODIFIED) {
49: updateExpirationInfo(cr, request, reply);
50: } else {
51: super.revalidateResource(cr, request, reply);
52: }
53: }
54: }
|