org.objectweb.mobilitools.smi.lib
Class ClassCache

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--org.objectweb.mobilitools.smi.lib.ClassCache
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class ClassCache
extends java.util.Hashtable

MobiliTools $Name: $, $Id: ClassCache.java,v 1.1.1.1 2003/03/28 14:48:06 dillense Exp $

Cache for classes, bytecode and any resource associated to a given codebase. A cache singleton is managed for each codebase value. A counter is maintained for each so that the cache is cleared when its codebase is not used by any agent any more.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
protected static java.util.Hashtable caches
           
protected  long refCount
           
 
Constructor Summary
protected ClassCache()
           
 
Method Summary
static void dec(java.lang.String codebase)
          Decrements the reference counter of the cache associated to the given codebase.
static ClassCache getCache(java.lang.String codebase)
          Ensure that a cache exists for the given codebase - creating a new cache instance if necessary - and returns its reference.
static void inc(java.lang.String codebase)
          Increments the reference counter of the cache associated to the given codebase.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

caches

protected static java.util.Hashtable caches

refCount

protected volatile long refCount
Constructor Detail

ClassCache

protected ClassCache()
Method Detail

getCache

public static ClassCache getCache(java.lang.String codebase)
Ensure that a cache exists for the given codebase - creating a new cache instance if necessary - and returns its reference. In other words, there is a cache singleton for each given codebase value.
Parameters:
codebase - the codebase associated to the cache
Returns:
the cache associated to the given codebase

inc

public static void inc(java.lang.String codebase)
Increments the reference counter of the cache associated to the given codebase. Does nothing if no cache exists for the given codebase.
Parameters:
codebase - the codebase of the target cache.

dec

public static void dec(java.lang.String codebase)
Decrements the reference counter of the cache associated to the given codebase. If the reference counter's new value is zero, then the cache is cleared. Does nothing if no cache exists for the given codebase.
Parameters:
codebase - the codebase of the target cache.