wt.units.dbService
Class UnitCache

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

public class UnitCache
extends CacheManager

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

See Also:
Serialized Form

Field Summary
private static UnitCache cache
           
private static int CACHESIZE
           
private static HashMap currentThreads
           
private static Object dataLock
           
private static Object flushLock
           
private static HashMap measurementSystems
           
private static boolean populated
           
private static HashMap quantityOfMeasures
           
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
UnitCache()
          Do not directly invoke this constructor! Use getUnitCache instead.
 
Method Summary
private  Object aquireLock()
           
private  void blockOnLock()
           
protected  void clear()
           
 int getDefaultSize()
          Get desired size of this cache.
 MeasurementSystem getMeasurementSystem(String name)
           
 String[] getMeasurementSystemNames()
           
 MeasurementSystem[] getMeasurementSystems()
           
 QuantityOfMeasure getQuantityOfMeasure(String name)
           
 String[] getQuantityOfMeasureNames()
           
 QuantityOfMeasure[] getQuantityOfMeasures()
           
static UnitCache getUnitCache()
          Contruct a new Unit cache.
 void populateCache()
           
 void Print()
           
 void putEntry(Object key, Object value)
          Overrides CacheManager.putEntry to do nothing so that no entries are added to the wt.util.Cache object contained in CacheManager.
private  void releaseLock(Object localLock)
           
protected  void removeEntry(Object target)
          Simply clear local cache when signalled.
 void reset()
          Method called when connection to master cache is broken and recovered indicating that a notification from another IBADefinition cache might have been missed.
 
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

dataLock

private static Object dataLock

flushLock

private static Object flushLock

currentThreads

private static HashMap currentThreads

quantityOfMeasures

private static HashMap quantityOfMeasures

measurementSystems

private static HashMap measurementSystems

populated

private static boolean populated

cache

private static UnitCache cache

VERBOSE

private static final boolean VERBOSE

CACHESIZE

private static int CACHESIZE
Constructor Detail

UnitCache

public UnitCache()
          throws RemoteException
Do not directly invoke this constructor! Use getUnitCache 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

getUnitCache

public static UnitCache getUnitCache()
Contruct a new Unit cache.


removeEntry

protected void removeEntry(Object target)
Simply clear local cache when signalled. Will be repopulated on subsequent requests

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

putEntry

public void putEntry(Object key,
                     Object value)
Overrides CacheManager.putEntry to do nothing so that no entries are added to the wt.util.Cache object contained in CacheManager.

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

clear

protected void clear()

reset

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

Overrides:
reset in class CacheManager

populateCache

public void populateCache()
                   throws WTException
Throws:
WTException

Print

public void Print()

getMeasurementSystem

public MeasurementSystem getMeasurementSystem(String name)
                                       throws WTException
Throws:
WTException

getMeasurementSystemNames

public String[] getMeasurementSystemNames()
                                   throws WTException
Throws:
WTException

getMeasurementSystems

public MeasurementSystem[] getMeasurementSystems()
                                          throws WTException
Throws:
WTException

getQuantityOfMeasure

public QuantityOfMeasure getQuantityOfMeasure(String name)
                                       throws WTException
Throws:
WTException

getQuantityOfMeasureNames

public String[] getQuantityOfMeasureNames()
                                   throws WTException
Throws:
WTException

getQuantityOfMeasures

public QuantityOfMeasure[] getQuantityOfMeasures()
                                          throws WTException
Throws:
WTException

aquireLock

private Object aquireLock()

releaseLock

private void releaseLock(Object localLock)

blockOnLock

private void blockOnLock()