net.spy.factory
Class Storage<T>

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.factory.Storage<T>

public class Storage<T>
extends SpyObject

An implementation of CacheEntry that is backed by a HashMap. This implementation will find any public methods on the given objects containing a CacheKey annotation, or any fields with any visibility declared only within the classes of the given objects and use them as cache hints.


Constructor Summary
Storage(java.util.Collection<T> obs)
          Get an instance of HashCacheEntry.
 
Method Summary
 void cacheInstance(T i)
          Cache this instance.
 java.util.Collection<T> getAllObjects()
          Get all of the objects in this cache.
 T getObject(java.lang.String cacheName, java.lang.Object key)
          Get a specific object by cache name and key.
 java.util.Collection<T> getObjects(java.lang.String cacheName, java.lang.Object key)
          Get the objects multicached to a particular key.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Storage

public Storage(java.util.Collection<T> obs)
Get an instance of HashCacheEntry.

Method Detail

cacheInstance

public void cacheInstance(T i)
                   throws java.lang.Exception
Cache this instance.

Throws:
java.lang.Exception

getAllObjects

public java.util.Collection<T> getAllObjects()
Get all of the objects in this cache.

Returns:
an unmodifiable collection of object instances

getObject

public T getObject(java.lang.String cacheName,
                   java.lang.Object key)
Get a specific object by cache name and key.

Parameters:
cacheName - the name of the cache containing the object
key - the key under which the object is cached
Returns:
the object, or null if there's no match

getObjects

public java.util.Collection<T> getObjects(java.lang.String cacheName,
                                          java.lang.Object key)
Get the objects multicached to a particular key.

Parameters:
cacheName - the name of the cache containing the objects
key - the key under which the objects are cached
Returns:
all the matching objects, or an empty collection if no match


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.