org.mmbase.cache
Class CachePolicy

java.lang.Object
  extended by org.mmbase.cache.CachePolicy
All Implemented Interfaces:
Serializable

public abstract class CachePolicy
extends Object
implements Serializable

A CachePolicy object determines for a given object whether it should be cached or not, and how. Code that makes use of a cache should use a CachePolicy object, when available, to determine if the object should be cached or not.

Since:
MMBase 1.8
Version:
$Id: CachePolicy.java 41943 2010-04-16 17:18:19Z michiel $
Author:
Pierre van Rooden
See Also:
Serialized Form

Field Summary
static CachePolicy ALWAYS
          Standard cache policy that advises to always cache a passed object.
static CachePolicy NEVER
          Standard cache policy that advises to never cache a passed object.
 
Constructor Summary
protected CachePolicy()
          Instantiates a new cache policy without registering it
protected CachePolicy(Object policyKey)
          Instantiates a new cache policy, and registers it with the given policy key.
 
Method Summary
abstract  boolean checkPolicy(Object o)
          Checks whether the policy advises to cache the passed object.
 String getDescription()
          Returns a description of the policy.
static CachePolicy getPolicy(Object policyKey)
          Obtains a cache policy given a policy key.
static void putPolicy(Object policyKey, CachePolicy policy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEVER

public static final CachePolicy NEVER
Standard cache policy that advises to never cache a passed object. Accessible with the key "never".


ALWAYS

public static final CachePolicy ALWAYS
Standard cache policy that advises to always cache a passed object. Accessible with the key "always".

Constructor Detail

CachePolicy

protected CachePolicy(Object policyKey)
Instantiates a new cache policy, and registers it with the given policy key.


CachePolicy

protected CachePolicy()
Instantiates a new cache policy without registering it

Method Detail

getPolicy

public static CachePolicy getPolicy(Object policyKey)
Obtains a cache policy given a policy key.

Parameters:
policyKey - the key of the cache policy
Returns:
the policy key
Throws:
IllegalArgumentException - if the policy does not exist

putPolicy

public static void putPolicy(Object policyKey,
                             CachePolicy policy)

checkPolicy

public abstract boolean checkPolicy(Object o)
Checks whether the policy advises to cache the passed object.

Parameters:
o - the object to check the cache for
Returns:
true if the policy advises to cache this object, false otherwise.

getDescription

public String getDescription()
Returns a description of the policy.



MMBase 2.0-SNAPSHOT - null