com.bowstreet.builders.webapp.methods
Class VariableCache

java.lang.Object
  extended by com.bowstreet.builders.webapp.methods.VariableCache

public abstract class VariableCache
extends java.lang.Object

Base class for variable cache implementations. A VariableCache manages a cache of instance values for a particular model/variable (across all profiles). A new VariableCache implementation can be used by setting the property bowstreet.variableCache.implementationClass to the name of a class that extends VariableCache.


Constructor Summary
VariableCache()
           
 
Method Summary
abstract  void clear()
           
abstract  java.lang.Object get(WebAppAccess webAppAccess, java.lang.String variableName)
          Get object from cache.
 java.lang.String getCacheName()
          Get the name of the variable this cache is for.
 int getHits()
          Get the current number of hits to this cache.
 int getMaximumSize()
          Get the maximum size for this cache.
 int getMisses()
          Get the current number of misses to this cache.
abstract  int getNumCacheEntries()
          Get the current number of entries in this cache.
 void incrementCounters(boolean bHit)
          Increment hit counts - pass true for hit, false for miss
 void initialize(WebApp webApp, java.lang.String cacheName, int size)
          Initialize this VariableCache instance.
 java.lang.String makeInstanceKey(WebAppAccess webAppAccess, java.lang.String variableName)
          Method to generate a key for a WebApp instance.
abstract  void put(WebAppAccess webAppAccess, java.lang.String variableName, java.lang.Object value)
          Store an object in cache.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableCache

public VariableCache()
Method Detail

clear

public abstract void clear()

get

public abstract java.lang.Object get(WebAppAccess webAppAccess,
                                     java.lang.String variableName)
Get object from cache. Return null if not available in cache.

Parameters:
webAppAccess - The WebApp session instance.
variableName - The name of the variable
Returns:
The data from cache, or null if not available in cache.

getCacheName

public java.lang.String getCacheName()
Get the name of the variable this cache is for.

Returns:
The cached variable's name.

getHits

public int getHits()
Get the current number of hits to this cache.

Returns:
Number of hits.

getMaximumSize

public int getMaximumSize()
Get the maximum size for this cache.

Returns:
Maximum cache size.

getMisses

public int getMisses()
Get the current number of misses to this cache.

Returns:
Number of misses.

getNumCacheEntries

public abstract int getNumCacheEntries()
Get the current number of entries in this cache.

Returns:
The number of entries currently held in cache.

incrementCounters

public void incrementCounters(boolean bHit)
Increment hit counts - pass true for hit, false for miss

Parameters:
bHit - True if this was a hit; false if a miss.

initialize

public void initialize(WebApp webApp,
                       java.lang.String cacheName,
                       int size)
Initialize this VariableCache instance. Subclasses should call super.initialize during their initialize code.

Parameters:
webApp - The WebApp associated with this variable.
cacheName - The name of the cache.
size - The maximum size of the cache.

makeInstanceKey

public java.lang.String makeInstanceKey(WebAppAccess webAppAccess,
                                        java.lang.String variableName)
Method to generate a key for a WebApp instance.

Parameters:
webAppAccess - The WebApp instance.
Returns:
A key representing the unique model instance data.

put

public abstract void put(WebAppAccess webAppAccess,
                         java.lang.String variableName,
                         java.lang.Object value)
Store an object in cache.

Parameters:
webAppAccess - The WebApp session instance.
variableName - Name of the variable we are caching.
value - The value to store in cache.


Copyright © 2009 IBM. All Rights Reserved.