wt.vc.views
Class ViewCache

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

public class ViewCache
extends CacheManager

A cache of all View and ViewAssociation objects.

See Also:
Serialized Form

Field Summary
private  Hashtable children
           
private static String CHILDREN_CACHE_KEY
           
private  boolean initialized
           
private  Hashtable parents
           
private static String PARENTS_CACHE_KEY
           
private static boolean VERBOSE
           
private  View[] views
           
private static String VIEWS_BY_NAME_CACHE_KEY
           
private static String VIEWS_BY_OID_CACHE_KEY
           
private static String VIEWS_CACHE_KEY
           
private static String VIEWS_TRANSACTION_CACHE
           
private  Hashtable viewsByName
           
private  Hashtable viewsByOid
           
 
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
 
Fields inherited from interface wt.cache.CacheServer
versionID
 
Constructor Summary
ViewCache()
          Construct an empty view cache.
 
Method Summary
protected  void addParentChildToContextCache(View parent, View child)
           
private  Object[] addToArray(Object[] array, Object element)
           
protected  void addViewChangeToContextCache(View view)
           
private  void clear()
           
protected  void clearContextCache()
           
 View[] getAllViews()
          Get all views.
 ObjectIdentifier[] getChildren(ObjectIdentifier parent_key)
          Get children of a view.
private  Hashtable getContextCache()
           
 int getDefaultSize()
          Get desired size of the managed cache.
 ObjectIdentifier getParent(ObjectIdentifier child_key)
          Get parent of a view.
 View getView(Object key)
          Get the View object corresponding to a object identifier or name.
private  void init()
           
private  void initializeContextCache()
           
private  boolean isContextCacheInitialized()
           
 void put(Object key, Object value)
          Signal a new or updated View or ViewAssociation object.
 void remove(Object key)
          Signal a removed View or ViewAssociation object.
protected  void removeEntry(Object key)
          Protected method called to remove an entry of the managed cache.
private  Object[] removeFromArray(Object[] array, Object element)
           
protected  void removeParentChildInContextCache(View parent, View child)
           
 void reset()
          Method called when connection to master cache is broken and recovered indicating that a notification from another view cache might have been missed.
 
Methods inherited from class wt.cache.CacheManager
checkAccess, get, getDefaultName, getEntry, isCacheHost, overflow, ping, putEntry, putEntry, reference, registerSlave, 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

VIEWS_TRANSACTION_CACHE

private static final String VIEWS_TRANSACTION_CACHE
See Also:
Constant Field Values

VIEWS_CACHE_KEY

private static final String VIEWS_CACHE_KEY
See Also:
Constant Field Values

views

private View[] views

VIEWS_BY_OID_CACHE_KEY

private static final String VIEWS_BY_OID_CACHE_KEY
See Also:
Constant Field Values

viewsByOid

private Hashtable viewsByOid

VIEWS_BY_NAME_CACHE_KEY

private static final String VIEWS_BY_NAME_CACHE_KEY
See Also:
Constant Field Values

viewsByName

private Hashtable viewsByName

PARENTS_CACHE_KEY

private static final String PARENTS_CACHE_KEY
See Also:
Constant Field Values

parents

private Hashtable parents

CHILDREN_CACHE_KEY

private static final String CHILDREN_CACHE_KEY
See Also:
Constant Field Values

children

private Hashtable children

initialized

private boolean initialized

VERBOSE

private static final boolean VERBOSE
See Also:
Constant Field Values
Constructor Detail

ViewCache

public ViewCache()
          throws RemoteException
Construct an empty view cache. Cache is registered as a slave of master cache at this time. Cache will be initialized when first used.

Method Detail

getDefaultSize

public int getDefaultSize()
Get desired size of the managed cache. The view cache uses the managed class only as a signalling mechanism, so the default size is 1.

Supported API: false

Overrides:
getDefaultSize in class CacheManager

init

private void init()
           throws WTException
Throws:
WTException

clear

private void clear()

put

public void put(Object key,
                Object value)
Signal a new or updated View or ViewAssociation object. Currently, this just causes the current cache to be cleared and reinitialized later, but it could actively maintain the cache in the future.

Overrides:
put in class CacheManager
Parameters:
key - an ObjectIdentifier
value - the new or changed object

removeEntry

protected void removeEntry(Object key)
Protected method called to remove an entry of the managed cache. This signals a new or updated View or ViewAssociation object. Currently, this just causes the current cache to be cleared and reinitialized later, but it could actively maintain the cache in the future.

Overrides:
removeEntry in class CacheManager
Parameters:
key - an ObjectIdentifier

reset

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

Overrides:
reset in class CacheManager

remove

public void remove(Object key)
Signal a removed View or ViewAssociation object. Currently, this just causes the current cache to be cleared and reinitialized later, but it could actively maintain the cache in the future.

Overrides:
remove in class CacheManager
Parameters:
key - an ObjectIdentifier

getView

public View getView(Object key)
             throws WTException
Get the View object corresponding to a object identifier or name. If the key is a String, it is assumed to be the name of the View, otherwise it is expected to be the object identifier of the View.

Parameters:
key - an ObjectIdentifier or View name
Returns:
the View object or null if not found
Throws:
WTException

getParent

public ObjectIdentifier getParent(ObjectIdentifier child_key)
                           throws WTException
Get parent of a view.

Parameters:
child_key - ObjectIdentifier of the child view
Returns:
the ObjectIdentifier of the parent view or null if no parent view
Throws:
WTException

getChildren

public ObjectIdentifier[] getChildren(ObjectIdentifier parent_key)
                               throws WTException
Get children of a view.

Parameters:
parent_key - ObjectIdentifier of the parent view
Returns:
array of child ObjectIdentifier or null if no children
Throws:
WTException

getAllViews

public View[] getAllViews()
                   throws WTException
Get all views.

Returns:
array of all view objects
Throws:
WTException

isContextCacheInitialized

private boolean isContextCacheInitialized()

initializeContextCache

private void initializeContextCache()
                             throws WTException
Throws:
WTException

getContextCache

private Hashtable getContextCache()
                           throws WTException
Throws:
WTException

clearContextCache

protected void clearContextCache()

addToArray

private Object[] addToArray(Object[] array,
                            Object element)

removeFromArray

private Object[] removeFromArray(Object[] array,
                                 Object element)

addViewChangeToContextCache

protected void addViewChangeToContextCache(View view)
                                    throws WTException
Throws:
WTException

addParentChildToContextCache

protected void addParentChildToContextCache(View parent,
                                            View child)
                                     throws WTException
Throws:
WTException

removeParentChildInContextCache

protected void removeParentChildInContextCache(View parent,
                                               View child)
                                        throws WTException
Throws:
WTException