KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > cache > AbstractCacheFilterChain


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.server.cache;
30
31 import com.caucho.server.connection.AbstractHttpResponse;
32 import com.caucho.server.connection.CauchoRequest;
33
34 import javax.servlet.FilterChain JavaDoc;
35 import java.io.IOException JavaDoc;
36 import java.io.OutputStream JavaDoc;
37 import java.io.Writer JavaDoc;
38 import java.util.ArrayList JavaDoc;
39
40 /**
41  * Represents the final servlet in a filter chain.
42  */

43 abstract public class AbstractCacheFilterChain implements FilterChain JavaDoc {
44   /**
45    * fillFromCache is called when the client needs the entire result, and
46    * the result is already in the cache.
47    *
48    * @param req the servlet request trying to get data from the cache
49    * @param response the servlet response which will receive data
50    * @param entry the cache entry to use
51    * @param isTop if true, the not-modified should be sent to the browser
52    */

53   abstract public boolean fillFromCache(CauchoRequest req,
54                     AbstractHttpResponse response,
55                     AbstractCacheEntry abstractEntry,
56                     boolean isTop)
57     throws IOException JavaDoc;
58   
59   /**
60    * Starts the caching after the headers have been sent.
61    *
62    * @param req the servlet request
63    * @param req the servlet response
64    * @param keys the saved header keys
65    * @param values the saved header values
66    * @param contentType the response content type
67    * @param charEncoding the response character encoding
68    *
69    * @return the output stream to store the cache value or null if
70    * uncacheable.
71    */

72   abstract public OutputStream JavaDoc startByteCaching(CauchoRequest req,
73                         AbstractHttpResponse res,
74                         ArrayList JavaDoc<String JavaDoc> keys,
75                         ArrayList JavaDoc<String JavaDoc> values,
76                         String JavaDoc contentType,
77                         String JavaDoc charEncoding,
78                         long contentLength);
79   
80   /**
81    * Starts the caching after the headers have been sent.
82    *
83    * @param req the servlet request
84    * @param req the servlet response
85    * @param keys the saved header keys
86    * @param values the saved header values
87    * @param contentType the response content type
88    * @param charEncoding the response character encoding
89    *
90    * @return the output stream to store the cache value or null if
91    * uncacheable.
92    */

93   abstract public Writer JavaDoc startCharCaching(CauchoRequest req,
94                       AbstractHttpResponse res,
95                       ArrayList JavaDoc<String JavaDoc> keys,
96                       ArrayList JavaDoc<String JavaDoc> values,
97                       String JavaDoc contentType,
98                       String JavaDoc charEncoding,
99                       long contentLength);
100   /**
101    * Update the headers when the caching has finished.
102    *
103    * @param okay if true, the cache if valid
104    */

105   abstract public void finishCaching(boolean okay);
106 }
107
Popular Tags