org.apache.jetspeed.cache.disk
Class JetspeedDiskCache

java.lang.Object
  extended byorg.apache.jetspeed.cache.disk.JetspeedDiskCache
All Implemented Interfaces:
DiskCache

public class JetspeedDiskCache
extends java.lang.Object
implements DiskCache

Sample Implementation of the Disk Cache interface.

Entries are updated when DiskCacheDaemon runs

Version:
$Id: JetspeedDiskCache.java,v 1.50 2004/02/23 02:45:29 jford Exp $
Author:
Kevin A. Burton, Santiago Gala
See Also:
DiskCache, DiskCacheDaemon

Field Summary
static java.lang.String DEFAULT_CACHE_DIRECTORY
          The default cache folder
 
Method Summary
 void add(java.lang.String url)
          Add this URL to the disk cache
 void add(java.lang.String url, boolean force)
           
 java.lang.String fetch(java.lang.String url, java.lang.String cache)
          Get the URL from the Internet and then place it in the File dest.
 java.lang.String fetch(java.lang.String url, java.lang.String cache, boolean force)
          Pulls in the remote URL from the net and saves it to disk
 DiskCacheEntry[] getEntries()
          Get a list of all the documents within the cache...
 DiskCacheEntry getEntry(java.lang.String url)
           Take the given remove URL and place it in the disk cache.
 DiskCacheEntry getEntry(java.lang.String url, boolean force)
          Force this URL to update
 DiskCacheEntry getEntry(java.lang.String url, java.io.Reader is)
          Get an Entry given a Reader and the URL from which it has been fetched.
static JetspeedDiskCache getInstance()
          Return the default instance of the JetspeedDiskCache cache.
static JetspeedDiskCache getInstance(java.lang.String directory)
          Return the default instance of the JetspeedDiskCache cache.
 java.lang.String getRoot()
          Return the root of this DiskCache
 boolean isCached(java.lang.String url)
          Ask if a url is in the DiskCache
 void refresh(java.lang.String url)
          Tell the DiskCache that this URL should be refreshed.
 void remove(java.lang.String url)
          Remove this URL from the disk cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CACHE_DIRECTORY

public static java.lang.String DEFAULT_CACHE_DIRECTORY
The default cache folder

Method Detail

getEntries

public DiskCacheEntry[] getEntries()
Get a list of all the documents within the cache... Modified to create the entries in the hashtable...

Specified by:
getEntries in interface DiskCache
See Also:
DiskCache.getEntries()

getRoot

public java.lang.String getRoot()
Return the root of this DiskCache

Specified by:
getRoot in interface DiskCache
See Also:
DiskCache.getRoot()

getEntry

public DiskCacheEntry getEntry(java.lang.String url)
                        throws java.io.IOException
Description copied from interface: DiskCache

Take the given remove URL and place it in the disk cache. Additionaly operations include building a DiskCacheEntry and then returning it.

getEntry may attempt to pull down the URL if it is not in the disk cache. Most implementations may provide support for changing this behavior so that you have to explicitly call add. This is done for performance reasons so that HTTP clients don't end up triggering a URL connection to fetch the given URL.

Specified by:
getEntry in interface DiskCache
Throws:
java.io.IOException
See Also:
DiskCache.getEntry( String url )

getEntry

public DiskCacheEntry getEntry(java.lang.String url,
                               boolean force)
                        throws java.io.IOException
Force this URL to update

Specified by:
getEntry in interface DiskCache
Throws:
java.io.IOException
See Also:
DiskCache.getEntry( String url )

getEntry

public DiskCacheEntry getEntry(java.lang.String url,
                               java.io.Reader is)
                        throws java.io.IOException
Get an Entry given a Reader and the URL from which it has been fetched.

Specified by:
getEntry in interface DiskCache
Throws:
java.io.IOException
See Also:
DiskCache.getEntry( String url, Reader is )

remove

public void remove(java.lang.String url)
            throws java.io.IOException
Description copied from interface: DiskCache
Remove this URL from the disk cache.

Specified by:
remove in interface DiskCache
Throws:
java.io.IOException
See Also:
DiskCache.remove( String url )

add

public void add(java.lang.String url)
         throws java.io.IOException
Description copied from interface: DiskCache
Add this URL to the disk cache

Specified by:
add in interface DiskCache
Throws:
java.io.IOException
See Also:
DiskCache.add( String url )

add

public void add(java.lang.String url,
                boolean force)
         throws java.io.IOException
Throws:
java.io.IOException
See Also:
DiskCache.add( String url )

fetch

public java.lang.String fetch(java.lang.String url,
                              java.lang.String cache)
                       throws java.io.IOException
Description copied from interface: DiskCache
Get the URL from the Internet and then place it in the File dest.

Specified by:
fetch in interface DiskCache
Parameters:
url - the url to retrieve
cache - what file to store it in.
Throws:
java.io.IOException
See Also:
DiskCache.fetch( String url, String cache )

fetch

public java.lang.String fetch(java.lang.String url,
                              java.lang.String cache,
                              boolean force)
                       throws java.io.IOException
Pulls in the remote URL from the net and saves it to disk

Parameters:
url - the url to retrieve
cache - what file to store it in.
Throws:
java.io.IOException
See Also:
DiskCache.fetch( String url, String cache )

refresh

public void refresh(java.lang.String url)
Description copied from interface: DiskCache
Tell the DiskCache that this URL should be refreshed. This will do this in a threaded and asynchronous manner.

Specified by:
refresh in interface DiskCache
See Also:
DiskCache.refresh(java.lang.String)

getInstance

public static JetspeedDiskCache getInstance()
Return the default instance of the JetspeedDiskCache cache.


getInstance

public static JetspeedDiskCache getInstance(java.lang.String directory)
Return the default instance of the JetspeedDiskCache cache.


isCached

public boolean isCached(java.lang.String url)
Description copied from interface: DiskCache
Ask if a url is in the DiskCache

Specified by:
isCached in interface DiskCache


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.