wt.fc.cache
Class CacheTable

java.lang.Object
  extended bywt.fc.cache.CacheTable
All Implemented Interfaces:
ApplicationContextChild
Direct Known Subclasses:
ReferenceCache.ObjectReferenceCacheTable

public class CacheTable
extends Object
implements ApplicationContextChild

Maintains a configurable set of Cache instances for a set of requestor objects. Application context entries are used to configure what specific cache instance is used for a given object.

Each CacheTable is constructed with a name, which must map to a set of application context entries as follows:

wt.services/rsc/default/<>/null/<>/0=<> wt.services/rsc/default/<>/<>.Size/null/0=<> wt.services/rsc/default/<>/<>.ReportInterval/null/0=<>

The first line above configures the logical name of the cache to be used for the given classname. This name is used when displaying report metrics. The next two lines configure the size of the cache, and the interval after which hit/miss metrics about the cache are printed. The size and report intervals can be assigned defaults by ommiting the cache name prefix. (See below). A report interval of zero will turn off cache reporting.

The following example configures a CacheTable named "ExampleCache", with a shared cache for documents and parts and a general cache for other Iterated objects. The special cache also overrides the default report interval settings. To use these entries, a CacheTable instance would need to be constructed with "ExampleCache" as its name.

wt.services/rsc/default/ExampleCache/null/wt.vc.Iterated/0=General wt.services/rsc/default/ExampleCache/null/wt.part.WTPart/0=Special wt.services/rsc/default/ExampleCache/null/wt.doc.WTDocument/0=Special wt.services/rsc/default/ExampleCache/Size/null/0=200 wt.services/rsc/default/ExampleCache/ReportInterval/null/0=2000 wt.services/rsc/default/ExampleCache/Special.ReportInterval/null/0=1000

Supported API: false

Extendable: false


Field Summary
private  ApplicationContext applicationContext
           
private  Map classMapping
          Maps class names to cache instances.
private static String CLASSNAME
           
private static boolean DEBUG
           
private static String DOT_REPORT_INTERVAL
           
private static String DOT_SIZE
           
protected  Object lock
           
private static DebugWriter LOG
           
 String name
          The name used to look up application context entries for this table.
private  Map nameMapping
          Maps cache names to cache instances.
private static String REPORT_INTERVAL
           
private static String RESOURCE
           
private static String SIZE
           
 
Fields inherited from interface wt.services.applicationcontext.ApplicationContextChild
APPLICATION_CONTEXT
 
Constructor Summary
CacheTable(String a_Name)
          Constructs a cache table with the given name and a synchronized HashMap for the class mappings table.
CacheTable(String a_Name, Map class_mapping)
          

Supported API: false
 
Method Summary
 void clear()
          Clears the content of all caches in the table

Supported API: false
protected  Cache createCache(String cache_name, int size, int report_interval)
          Instantiates a Cache with the given name, size, and report interval.
 Cache get(String class_name)
          Gets a cache for the given class name

Supported API: false
 ApplicationContext getApplicationContext()
          Gets the object for the association that plays role: applicationContext.
private  String getCacheName(String class_name)
           
 String getName()
          Gets the value of the attribute: name; The name used to look up application context entries for this table.
private  int getReportInterval(String cache_name)
           
private  int getSize(String cache_name)
           
 void setApplicationContext(ApplicationContext a_ApplicationContext)
          Sets the object for the association that plays role: applicationContext.
 String toString()
          Prints hit & miss counts for each cache in the table.
 void writeContents(Writer w)
          Prints the hit and miss counts for each cache in the table, as well as the contents of each cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

name

public final String name
The name used to look up application context entries for this table.

Supported API: false


classMapping

private final Map classMapping
Maps class names to cache instances.


nameMapping

private final Map nameMapping
Maps cache names to cache instances. Safe to use a HashMap because there will be a reasonably small number of cache names configured via app context


applicationContext

private ApplicationContext applicationContext

SIZE

private static final String SIZE
See Also:
Constant Field Values

DOT_SIZE

private static final String DOT_SIZE
See Also:
Constant Field Values

REPORT_INTERVAL

private static final String REPORT_INTERVAL
See Also:
Constant Field Values

DOT_REPORT_INTERVAL

private static final String DOT_REPORT_INTERVAL
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG

LOG

private static final DebugWriter LOG

lock

protected final Object lock
Constructor Detail

CacheTable

public CacheTable(String a_Name)
Constructs a cache table with the given name and a synchronized HashMap for the class mappings table. The other constructor can be used to specify an alternate Map implementation.

Supported API: false

Parameters:
a_Name -

CacheTable

public CacheTable(String a_Name,
                  Map class_mapping)


Supported API: false

Parameters:
a_Name -
class_mapping -
Method Detail

getName

public final String getName()
Gets the value of the attribute: name; The name used to look up application context entries for this table.

Supported API: false

Returns:
String

clear

public void clear()
Clears the content of all caches in the table

Supported API: false


get

public Cache get(String class_name)
          throws WTException
Gets a cache for the given class name

Supported API: false

Parameters:
class_name -
Returns:
Cache
Throws:
WTException

writeContents

public void writeContents(Writer w)
                   throws IOException
Prints the hit and miss counts for each cache in the table, as well as the contents of each cache.

Supported API: false

Parameters:
w -
Throws:
IOException

toString

public String toString()
Prints hit & miss counts for each cache in the table.

Supported API: false

Returns:
String

createCache

protected Cache createCache(String cache_name,
                            int size,
                            int report_interval)
Instantiates a Cache with the given name, size, and report interval. The default implementation does not use the name parameter.

Supported API: false

Parameters:
cache_name -
size -
report_interval -
Returns:
Cache

getApplicationContext

public ApplicationContext getApplicationContext()
Gets the object for the association that plays role: applicationContext.

Supported API: false

Specified by:
getApplicationContext in interface ApplicationContextChild
Returns:
ApplicationContext

setApplicationContext

public void setApplicationContext(ApplicationContext a_ApplicationContext)
                           throws WTPropertyVetoException
Sets the object for the association that plays role: applicationContext.

Supported API: false

Specified by:
setApplicationContext in interface ApplicationContextChild
Parameters:
a_ApplicationContext -
Throws:
WTPropertyVetoException

getCacheName

private String getCacheName(String class_name)
                     throws WTException
Throws:
WTException

getSize

private int getSize(String cache_name)
             throws WTException
Throws:
WTException

getReportInterval

private int getReportInterval(String cache_name)
                       throws WTException
Throws:
WTException