Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.commons
Class NamedResources

    java.lang.Object
      org.makumba.commons.NamedResources

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  SoftNamedResources

    public class NamedResources

extends Object
implements Serializable

An instance of this class holds a cache of resources. If a resource is requested but is not present, it is produced using the associated NamedResourceFactory, in a thread-safe way

Version:
  $Id: NamedResources.java 3666 2009-01-15 21:28:06Z rosso_nero $
Author:
  Cristian Bogdan
See Also:
  `NamedResourceFactory`, Serialized Form

Field Summary
`(package private) static Vector<WeakReference<NamedResources>>` | `allCaches`
`(package private) NamedResourceFactory` | `f`
`(package private) int` | `hits`
`(package private) int` | `misses`
`(package private) String` | `name`
`(package private) static boolean` | `soft_static_caches`
`(package private) static List<NamedResources>` | `staticCaches`
`(package private) Map` | `values`

Constructor Summary
`NamedResources(String name, NamedResourceFactory f)` Initializes using the given factory

Method Summary
`static void` | `cleanCaches()`
`static void` | `cleanStaticCache(int n)` Cleans the given cache.
`static void` | `cleanStaticCache(String name)`
`static void` | `cleanup()` Cleans-up all the static and soft caches
`void` | `close()` Closes each contained object by calling its close() method, if any
`static Map<String,int[]>` | `getCacheInfo()` Wraps information about the cache into a Map
`String` | `getName()`
`protected NameValue` | `getNameValue(Object name, Object hash)`
`Object` | `getResource(Object name)` Gets a specific resource.
`static NamedResources` | `getStaticCache(int n)` Gets the static cache identified by n
`Object` | `getSupplementary()` Whatever supplementary stuff the factory wants to keep
`boolean` | `knowResource(Object name)` Checks if a resource is known
`static int` | `makeStaticCache(String name, NamedResourceFactory fact)` Creates a static cache
`static int` | `makeStaticCache(String name, NamedResourceFactory fact, boolean soft)` Creates a static cache
`int` | `size()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### soft_static_caches

    static boolean soft_static_caches

### f

    NamedResourceFactory f

### name

    String name

### values

    Map values

### hits

    int hits

### misses

    int misses

### staticCaches

    static List<NamedResources> staticCaches

### allCaches

    static Vector<WeakReference<NamedResources>> allCaches

Constructor Detail

### NamedResources

    public NamedResources(String name,
                          NamedResourceFactory f)

  Initializes using the given factory

  Parameters:
    `name` - the name of the NamedResources object to initalise
    `f` - the `NamedResourceFactory` used to construct the NamedResource

Method Detail

### cleanup

    public static void cleanup()

  Cleans-up all the static and soft caches

### cleanCaches

    public static void cleanCaches()

### makeStaticCache

    public static int makeStaticCache(String name,
                                      NamedResourceFactory fact,
                                      boolean soft)

  Creates a static cache

  Parameters:
    `name` - the name of the cache
    `fact` - the `NamdedResourceFactory` used to create the cache
    `soft` - `true` if this should be a soft cache
  Returns:
    The identifier of this cache

### makeStaticCache

    public static int makeStaticCache(String name,
                                      NamedResourceFactory fact)

  Creates a static cache

  Parameters:
    `name` - the name of the cache
    `fact` - the NamdedResourceFactory used to create the cache
  Returns:
    The identifier of this cache

### getStaticCache

    public static NamedResources getStaticCache(int n)

  Gets the static cache identified by n

  Parameters:
    `n` - the index of the cached object in the cache
  Returns:
    The cache of resources

### cleanStaticCache

    public static void cleanStaticCache(int n)

  Cleans the given cache. Use this for developing purposes.

  Parameters:
    `n` - the index of the cache to be cleaned

### cleanStaticCache

    public static void cleanStaticCache(String name)

### getCacheInfo

    public static Map<String,int[]> getCacheInfo()

  Wraps information about the cache into a Map

  Returns:
    A Map having as keys the names of the caches and as value an array of int containing the size, hits and misses of each cache

### knowResource

    public boolean knowResource(Object name)

  Checks if a resource is known

  Parameters:
    `name` - the name of the resource to be checked
  Returns:
    `true` if the resource is known, `false` otherwise

### getSupplementary

    public Object getSupplementary()

  Whatever supplementary stuff the factory wants to keep

  Returns:
    An object with the supplementary things the factory may need

### getResource

    public Object getResource(Object name)

  Gets a specific resource. If it doesn't exist, calls the NamedResourceFactory to produce it

  Parameters:
    `name` - the name of the resource to get
  Returns:
    The resource

### getNameValue

    protected NameValue getNameValue(Object name,
                                     Object hash)

### size

    public int size()

### getName

    public String getName()

### close

    public void close()

  Closes each contained object by calling its close() method, if any

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20