wt.team
Class TeamTemplateCache

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended bywt.util.RMIServer
              extended bywt.cache.CacheManager
                  extended bywt.team.TeamTemplateCache
All Implemented Interfaces:
CacheServer, Remote, Serializable, Unreferenced

public class TeamTemplateCache
extends CacheManager

This class implements a TeamTemplate cache service. It follows the 2-level cache paradigm. Creation and updates to TeamTemplate must be communicated to the cache by the Services manager.

See Also:
Serialized Form

Nested Class Summary
(package private) static class TeamTemplateCache.CachedTeamTemplates
           
static class TeamTemplateCache.TeamTemplateCacheReporter
           
(package private) static class TeamTemplateCache.TeamTemplateEntry
           
(package private)  class TeamTemplateCache.TeamTemplateIdentityCollationKeyFactory
           
(package private) static class TeamTemplateCache.UpdateMessage
           
 
Field Summary
private static boolean CACHE_ENABLED
           
private static int CACHESIZE
           
private static boolean ENABLED_ONLY
           
private static Object lock
           
private static boolean overflowed
           
private static String SEPARATOR
           
private static TeamTemplateCache teamTemplateCache
           
private static TeamTemplateCache.CachedTeamTemplates templatesByName
           
private static TeamTemplateCache.CachedTeamTemplates templatesByOID
           
private static boolean VERBOSE
           
private static String versionID
           
 
Fields inherited from class wt.cache.CacheManager
MASTER
 
Fields inherited from class wt.util.RMIServer
csf, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
TeamTemplateCache()
          Do not directly invoke this constructor! Use getTeamTemplateCache instead.
 
Method Summary
 int getDefaultSize()
          Get desired size of this cache.
 Enumeration getEntries(WTContainerRef cRef)
          Return a sorted enumeration of all TeamTemplates
private  String getKey(WTContainerRef container, String templateIdentity)
           
 TeamTemplate getTeamTemplate(TeamTemplateReference ttr)
           
protected static TeamTemplateCache getTeamTemplateCache()
           
 TeamTemplateReference getTeamTemplateReference(WTContainerRef containerRef, String teamName)
           
private static boolean isValid()
           
static void main(String[] args)
           
protected  void populateCache()
           
 void Print()
           
 void putEntry(Object key, Object value)
          Protected method which allows subclasses of CacheManager to take some action when a new entry is being put into the local cache.
protected  void removeEntry(Object a_msg)
          Protected method which allows subclasses of CacheManager to take some action when a entry is being removed from the local cache.
 void reset()
          Method called when connection to master cache is broken and recovered indicating that a notification from another template cache might have been missed.
 void update(TeamTemplate template, String action)
           
 
Methods inherited from class wt.cache.CacheManager
checkAccess, get, getDefaultName, getEntry, isCacheHost, overflow, ping, put, putEntry, reference, registerSlave, remove, remove, removeEntry, unreferenced, update, updateEntry, updateEntry
 
Methods inherited from class wt.util.RMIServer
clone, exportObject, exportObject, exportObject, getClientSocketFactory, getPort, getServerSocketFactory, getStub, isHostInList, isLocalHost, setPort, writeReplace
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

templatesByOID

private static TeamTemplateCache.CachedTeamTemplates templatesByOID

templatesByName

private static TeamTemplateCache.CachedTeamTemplates templatesByName

teamTemplateCache

private static volatile TeamTemplateCache teamTemplateCache

VERBOSE

private static final boolean VERBOSE

CACHESIZE

private static int CACHESIZE

CACHE_ENABLED

private static boolean CACHE_ENABLED

overflowed

private static boolean overflowed

lock

private static Object lock

ENABLED_ONLY

private static final boolean ENABLED_ONLY

SEPARATOR

private static final String SEPARATOR
See Also:
Constant Field Values
Constructor Detail

TeamTemplateCache

public TeamTemplateCache()
                  throws RemoteException
Do not directly invoke this constructor! Use getTeamTemplateCache instead. The constructor is public so that the ServerManager can create an instance of this class for use as the master cache.

However, since the master cache is only being used to signal slave caches, we don't want to construct any of the internal cache objects.

Method Detail

getTeamTemplateCache

protected static TeamTemplateCache getTeamTemplateCache()

getTeamTemplateReference

public TeamTemplateReference getTeamTemplateReference(WTContainerRef containerRef,
                                                      String teamName)

getTeamTemplate

public TeamTemplate getTeamTemplate(TeamTemplateReference ttr)

removeEntry

protected void removeEntry(Object a_msg)
Description copied from class: CacheManager
Protected method which allows subclasses of CacheManager to take some action when a entry is being removed from the local cache. This method is invoked to remove the entry in the local cache as a result of a local remove call or a call forwarded from a master cache. If this cache has a master cache, the remove call will already be forwarded to the master before this method is invoked. Slave caches will be notified to remove their entries after this method returns. This method must not cause a recursive remove call.

This method is not called when entries are being removed by the overflow or reset methods.

Supported API: true

Overrides:
removeEntry in class CacheManager
Parameters:
a_msg - the key object (null = clear entire cache)

putEntry

public void putEntry(Object key,
                     Object value)
Description copied from class: CacheManager
Protected method which allows subclasses of CacheManager to take some action when a new entry is being put into the local cache. This method is invoked to put the entry in the local cache as a result of a local put call or a call forwarded from a slave cache or when a local get call downloads the entry from a master cache. If this cache has a master cache, the put call will already be forwarded to the master before this method is invoked. Slave caches will be notified to remove their entries after this method returns. This method must not cause a recursive put call.

Supported API: true

Overrides:
putEntry in class CacheManager
Parameters:
key - the key object
value - the value object

getDefaultSize

public int getDefaultSize()
Description copied from class: CacheManager
Get desired size of this cache. This method attemps to find a size property called wt.cache.size.CacheName where cacheName is the name of this cache. Subclasses can override this method to control cache size in some other way. If no property is found, the default size is 100.

Supported API: true

Overrides:
getDefaultSize in class CacheManager

getEntries

public Enumeration getEntries(WTContainerRef cRef)
                       throws WTException
Return a sorted enumeration of all TeamTemplates

Throws:
WTException

populateCache

protected void populateCache()
                      throws WTException
Throws:
WTException

update

public void update(TeamTemplate template,
                   String action)

reset

public void reset()
Method called when connection to master cache is broken and recovered indicating that a notification from another template cache might have been missed. The current cache is cleared and reinitialized.

Overrides:
reset in class CacheManager

Print

public void Print()

isValid

private static boolean isValid()

main

public static void main(String[] args)

getKey

private String getKey(WTContainerRef container,
                      String templateIdentity)