org.jcreme.caches
Class CachePolicy

java.lang.Object
  extended byorg.jcreme.enumerations.Enumeration
      extended byorg.jcreme.caches.CachePolicy
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class CachePolicy
extends Enumeration

This Enumeration subclass describes the possible policies to manage the cache contents. Each member is a cache factory to be used by AggregateCache instances. Current implemented values are: NONE (this gives a HashCache): replacement is undefined. FIFO (this gives a FIFOCache): new elements push older ones. The oldest is removed. LUFO (this gives a LUFOCache): keep statistics on cache element usage. The least used element is removed. The policy choice for a cache depends heavily on the use of that cache.

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $
See Also:
Serialized Form

Field Summary
static CachePolicy FIFO
          The 'FIFO' enumeration value.
static CachePolicy LUFO
          The 'LUFO' enumeration value.
static CachePolicy NONE
          The 'NONE' enumeration value.
static java.lang.String S_FIFO
          The name for the 'FIFO' enumeration value.
static java.lang.String S_LUFO
          The name for the 'LUFO' enumeration value.
static java.lang.String S_NONE
          The name for the 'NONE' enumeration value.
(package private) static long serialVersionUID
           
 
Constructor Summary
protected CachePolicy(java.lang.String name)
          Creates new CachePolicy
 
Method Summary
static CachePolicy get(java.lang.String name)
          This method retrieves a CachePolicy instance from its name.
 BaseCache getCacheInstance()
          This method provides a new cache that implements the policy.
 BaseCache getCacheInstance(int minSize, int maxSize)
          This method provides a new cache that implements the policy.
static CachePolicy[] getCachePolicies()
          This methods gives the instances of this class.
protected  java.util.Hashtable getFromName()
          This method is for internal use only.
static Enumeration[] getValues()
          This method enables to retrieve all the possible values of an Enumeration class.
 
Methods inherited from class org.jcreme.enumerations.Enumeration
compareTo, getName, readResolve, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

S_FIFO

public static final java.lang.String S_FIFO
The name for the 'FIFO' enumeration value.

See Also:
Constant Field Values

FIFO

public static final CachePolicy FIFO
The 'FIFO' enumeration value.


S_LUFO

public static final java.lang.String S_LUFO
The name for the 'LUFO' enumeration value.

See Also:
Constant Field Values

LUFO

public static final CachePolicy LUFO
The 'LUFO' enumeration value.


S_NONE

public static final java.lang.String S_NONE
The name for the 'NONE' enumeration value.

See Also:
Constant Field Values

NONE

public static final CachePolicy NONE
The 'NONE' enumeration value.

Constructor Detail

CachePolicy

protected CachePolicy(java.lang.String name)
Creates new CachePolicy

Parameters:
name - the name of this enumerated value. It cannot be null.
Throws:
InvalidParameterException - if one of the parameters is null.
Method Detail

getFromName

protected java.util.Hashtable getFromName()
This method is for internal use only.

Specified by:
getFromName in class Enumeration
Returns:
the Hashtable that links the enumerated values names with the actual enumerated value.

get

public static CachePolicy get(java.lang.String name)
This method retrieves a CachePolicy instance from its name.

Parameters:
name - the name of the CachePolicy instance.
Returns:
the CachePolicy that has this name. Null if no value corresponding to this name was found.

getCachePolicies

public static CachePolicy[] getCachePolicies()
This methods gives the instances of this class.

Returns:
all the instances of this class.

getCacheInstance

public BaseCache getCacheInstance(int minSize,
                                  int maxSize)
This method provides a new cache that implements the policy.

Parameters:
minSize - the initial size of the cache.
maxSize - the maximum size of the created cache.
Returns:
a new cache that implements the policy.

getCacheInstance

public BaseCache getCacheInstance()
This method provides a new cache that implements the policy.

Returns:
a new cache that implements the policy.

getValues

public static Enumeration[] getValues()
This method enables to retrieve all the possible values of an Enumeration class.

Returns:
the values for this class.


Copyright 2006 null. All Rights Reserved.