KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > cache > disk > DiskCache


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.jetspeed.cache.disk;
18
19 import java.io.*;
20
21 /**
22 <p>
23 A way to store remote documents locally. This can increase performance by
24 eliminating TCP connection latency.
25 </p>
26
27 <p>
28 All implementations of a DiskCache should implement this interface.
29 </p>
30
31 @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
32 @author <a HREF="mailto:sgala@hisitech.com">Santiago Gala</a>
33 @version $Id: DiskCache.java,v 1.15 2004/02/23 02:45:29 jford Exp $
34 */

35 public interface DiskCache {
36     
37     /**
38     <p>
39     Take the given remove URL and place it in the disk cache. Additionaly
40     operations include building a DiskCacheEntry and then returning it.
41     </p>
42     
43     <p>getEntry may attempt to pull down the URL if it is not in the disk cache.
44     Most implementations may provide support for changing this behavior so that
45     you have to explicitly call add. This is done for performance reasons
46     so that HTTP clients don't end up triggering a URL connection to fetch
47     the given URL.</p>
48     
49     */

50     public DiskCacheEntry getEntry( String JavaDoc url ) throws IOException;
51
52     /**
53     <p>Get an Entry from the from the cache but force this URL to be fetched and
54     then cached no matter what configuration options Jetspeed provides.
55     
56     @see #getEntry( String url )
57     */

58     public DiskCacheEntry getEntry( String JavaDoc url,
59                                     boolean force ) throws IOException;
60     
61     /**
62     Get a entry based on a URL but you should already have the content. This is
63     usually used to specify an alternative Reader (maybe StringReader).
64
65     <p>getEntry may attempt to pull down the URL if it is not in the disk cache.
66     Most implementations may provide support for changing this behavior so that
67     you have to explicitly call add. This is done for performance reasons
68     so that HTTP clients don't end up triggering a URL connection to fetch
69     the given URL.</p>
70     
71     */

72     public DiskCacheEntry getEntry( String JavaDoc url, Reader is ) throws IOException;
73     
74     /**
75     Get a list of all the documents within the cache...
76     
77     */

78     public DiskCacheEntry[] getEntries();
79
80     /**
81     Add this URL to the disk cache
82     
83     */

84     public void add( String JavaDoc url ) throws IOException;
85     
86     /**
87     Remove this URL from the disk cache.
88     
89     */

90     public void remove( String JavaDoc url ) throws IOException;
91     
92
93     /**
94     Get the URL from the Internet and then place it in the File dest.
95     
96     */

97     public String JavaDoc fetch( String JavaDoc url, String JavaDoc destination ) throws IOException ;
98
99     /**
100     Return the root of this DiskCache.
101     
102     */

103     public String JavaDoc getRoot();
104
105     /**
106     Tell the DiskCache that this URL should be refreshed. This will do this in
107     a threaded and asynchronous manner.
108     
109     */

110     public void refresh( String JavaDoc url );
111
112     /**
113     Ask if a url is in the DiskCache
114     
115     */

116     public boolean isCached( String JavaDoc url );
117
118 }
119
Popular Tags