Class w3c.www.protocol.http.cache.CacheFilter
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.www.protocol.http.cache.CacheFilter

java.lang.Object
   |
   +----w3c.www.protocol.http.cache.CacheFilter

public class CacheFilter
extends Object
implements PropRequestFilter, PropertyMonitoring

Variable Index

 o CACHE_CONNECTED_P
Name of the property indicating wether the cache is connected or not.
 o CACHE_DIRECTORY_P
Name of the property giving the cache's directory.
 o CACHE_SIZE_P
The name of the properties indicating the size of the cache (in bytes).
 o CACHE_STATE_P
Name of the property giving the cache state file name.
 o connected
Is this cache connected ?
 o debug
The debug flag.
 o DEBUG_P
Name of the property indicating if the cache is in debug mode.
 o directory
The directory where the cache is stored.
 o expires_drift
The expires drift.
 o FILE_SIZE_RATIO_P
Name of the property indicating the max size for files to be cached.
 o fileSizeRatio
The file size quota.
 o GARBAGE_COLLECTION_ENABLED_P
Name of the property enabling garbage collection of the cache.
 o garbageCollectionEnabled
Should we enable garbage collection of the cache ?
 o props
The properties we initialized ourself from.
 o shared
Is this cached shared ?
 o SHARED_P
Name of the property indicating if this cache is shared.
 o size
The current cache size.
 o STATE_CACHABLE
 o STATE_RESOURCE
 o stats
Our real time statistics.

Constructor Index

 o CacheFilter()

Method Index

 o canCache(Request, Reply)
Can the given reply to the given request be added to the cache.
 o canUseCache(Request)
Can the given request be fullfilled by the cache filter ? This method distinguishes two situations.
 o getCacheSize()
Get the total size allocated to the cache.
 o getFile(URL)
 o getStatistics()
Get the statistics repository associated with that filter.
 o ingoingFilter(Request)
 o initialize(HttpManager)
Initialize a new reuqest manager.
 o isConnected()
Is this cache connected to the net ?
 o isGarbageCollectionEnabled()
Are we allow to run garbage collections at all ?
 o isShared()
Is this cache shared among multiple users ?
 o loadResource(String)
Try to load from the cache the resource's whose URL is gievn.
 o markUsed(CachedResource)
 o markUsed(CachedResource, int)
 o markUsed(CachedResource, int, int)
Mark the given cached resource as having been used recently.
 o outgoingFilter(Request, Reply)
 o propertyChanged(String)
PropertyMonitoring implementation - Commit property changes.
 o removeResource(String)
Remove a resource from the cache.
 o trace(Request, String)
 o updateCacheSpaceCounter(int)

Variables

 o CACHE_SIZE_P
  public final static String CACHE_SIZE_P
The name of the properties indicating the size of the cache (in bytes). This property will give the value of the disk-based cache size. This value only takes into account the size of the entities saved, not the size of the associated headers.

This property defaults to 5000000 bytes.

 o DEBUG_P
  public final static String DEBUG_P
Name of the property indicating if the cache is in debug mode.

This property defaults to false.

 o SHARED_P
  public final static String SHARED_P
Name of the property indicating if this cache is shared.

This property defaults to true.

 o CACHE_DIRECTORY_P
  public final static String CACHE_DIRECTORY_P
Name of the property giving the cache's directory. This property defaults to the current directory.
 o CACHE_CONNECTED_P
  public final static String CACHE_CONNECTED_P
Name of the property indicating wether the cache is connected or not. This property defaults to true.
 o GARBAGE_COLLECTION_ENABLED_P
  public final static String GARBAGE_COLLECTION_ENABLED_P
Name of the property enabling garbage collection of the cache. This property defaults to true.
 o FILE_SIZE_RATIO_P
  public final static String FILE_SIZE_RATIO_P
Name of the property indicating the max size for files to be cached. This property gives the ratio (relative to the cache size) of the number of bytes a single entry is able to occupy.

The ratio should be given as a floating point value between 0 and 1. If set to 0.1 and the cache size is 5000000, files larger then 500000 will not be cached (except if garbage collection is disbabled).

This property defaults to 0.1.

 o CACHE_STATE_P
  public final static String CACHE_STATE_P
Name of the property giving the cache state file name. This property defaults to cache.db in the current working directory.
 o STATE_CACHABLE
  public final static String STATE_CACHABLE
 o STATE_RESOURCE
  public final static String STATE_RESOURCE
 o props
  protected ObservableProperties props
The properties we initialized ourself from.
 o directory
  protected File directory
The directory where the cache is stored.
 o size
  protected int size
The current cache size.
 o debug
  protected boolean debug
The debug flag.
 o shared
  protected boolean shared
Is this cached shared ?
 o connected
  protected boolean connected
Is this cache connected ?
 o garbageCollectionEnabled
  protected boolean garbageCollectionEnabled
Should we enable garbage collection of the cache ?
 o fileSizeRatio
  protected double fileSizeRatio
The file size quota.

Indicates the percentage of cache size allowed to be occupied by a single file. This is not taken into account when garbage collection is disabled.

 o expires_drift
  protected long expires_drift
The expires drift.

Control if we will cache already expires documents, in the hope that revalidation will be enough to refresh them, or also because the cache will be used in disconnected mode.

 o stats
  protected cacheStatistics stats
Our real time statistics.

Constructors

 o CacheFilter
  public CacheFilter()

Methods

 o trace
  protected final void trace(Request request,
                             String msg)
 o updateCacheSpaceCounter
  protected final void updateCacheSpaceCounter(int delta)
 o isShared
  public boolean isShared()
Is this cache shared among multiple users ?
Returns:
A boolean true if shared, false otherwise.
 o isConnected
  public boolean isConnected()
Is this cache connected to the net ?
Returns:
A boolean, true if the cache is connected, false otherwise.
 o isGarbageCollectionEnabled
  public boolean isGarbageCollectionEnabled()
Are we allow to run garbage collections at all ?
Returns:
A boolean true if garbage collection is allowed , false otherwise.
 o getFile
  protected File getFile(URL url)
 o markUsed
  protected void markUsed(CachedResource resource,
                          int osize,
                          int nsize)
Mark the given cached resource as having been used recently.
Parameters:
resource - The CachedResource instance that has been used.
 o markUsed
  protected void markUsed(CachedResource resource,
                          int nsize)
 o markUsed
  protected void markUsed(CachedResource resource)
 o propertyChanged
  public boolean propertyChanged(String name)
PropertyMonitoring implementation - Commit property changes.
Parameters:
name - The name of the property that has changed.
Returns:
A boolean true if change was commited, false otherwise.
 o getCacheSize
  public int getCacheSize()
Get the total size allocated to the cache.
Returns:
The cache size as an integer.
 o initialize
  public void initialize(HttpManager manager)
Initialize a new reuqest manager. At this time, only one manager is allowed per application. This restriction will be removed either by using several managers, or by providing manager contexts.
Parameters:
manager - The manager to initialize.
 o getStatistics
  public cacheStatistics getStatistics()
Get the statistics repository associated with that filter.
Returns:
An instance of cacheStatistics.
 o loadResource
  public CachedResource loadResource(String url) throws InvalidResourceException
Try to load from the cache the resource's whose URL is gievn.
Parameters:
url - The String version of the url of the resource to load.
Returns:
An instance of CachedResource (or one of its subclasses), or null if not found.
 o removeResource
  public void removeResource(String urlloc)
Remove a resource from the cache.
Parameters:
urlloc - The URL of the resource to remove, encoded as a String.
 o canUseCache
  public boolean canUseCache(Request request)
Can the given request be fullfilled by the cache filter ? This method distinguishes two situations. It first check if anything in the request makes it uncachable, if this is the case, processing continues normally. If the request can be answered by the cache, we mark it as such by setting the w3c.www.protocol.http.cache state of the request to Boolean.TRUE, ans we return true.
Returns:
A boolean, true if the request can be fullfilled by the cache, false otherwise.
 o canCache
  public boolean canCache(Request request,
                          Reply reply)
Can the given reply to the given request be added to the cache. This method performs all checks to detect wether the given request, reply can be cached.

We don't check for expires or maxage here, since we expect some sites to use negative expires, or zero max age, just for the sake of revalidation (that's fine).

Returns:
A boolean true if we can cache, false otherwise.
 o ingoingFilter
  public Reply ingoingFilter(Request request) throws HttpException
 o outgoingFilter
  public Reply outgoingFilter(Request request,
                              Reply reply) throws HttpException

All Packages  Class Hierarchy  This Package  Previous  Next  Index