org.clazzes.util.lifecycle.impl
Class AbstractCacheImpl<T>

java.lang.Object
  extended by org.clazzes.util.lifecycle.impl.AbstractObjectFactoryImpl<T>
      extended by org.clazzes.util.lifecycle.impl.AbstractCacheImpl<T>
All Implemented Interfaces:
Cache<T>, ObjectFactory<T>

public abstract class AbstractCacheImpl<T>
extends AbstractObjectFactoryImpl<T>
implements Cache<T>

Abstract base class for Cache interface.

Concrete implementations must merely implement AbstractObjectFactoryImpl.createNew(Object) appropriately.

Author:
jpayr
See Also:
AbstractObjectFactoryImpl

Field Summary
protected  java.util.Hashtable<T,java.lang.ref.WeakReference<Cacheable<T>>> cache
           
 
Constructor Summary
AbstractCacheImpl()
           
 
Method Summary
 void addShareable(Cacheable<T> object)
          Adds a Cacheable object to the Cache.
 Cacheable<T> get(T key)
          Deliver an object for the passed key.
 
Methods inherited from class org.clazzes.util.lifecycle.impl.AbstractObjectFactoryImpl
createNew, internalCreateNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected transient java.util.Hashtable<T,java.lang.ref.WeakReference<Cacheable<T>>> cache
Constructor Detail

AbstractCacheImpl

public AbstractCacheImpl()
Method Detail

get

public Cacheable<T> get(T key)
Description copied from interface: ObjectFactory
Deliver an object for the passed key.

Specified by:
get in interface ObjectFactory<T>
Overrides:
get in class AbstractObjectFactoryImpl<T>
Parameters:
key - The key used to identify the object.
Returns:
the created object.

addShareable

public void addShareable(Cacheable<T> object)
Description copied from interface: Cache
Adds a Cacheable object to the Cache. References to this object can be retrieved with ObjectFactory.get(Object). If an object with the same id is already present in the cache, the given instance will be merged with the resident using the object's Cacheable.merge(Cacheable) method.

Specified by:
addShareable in interface Cache<T>
Parameters:
object - the object to be added to the cache.


Copyright © 2010. All Rights Reserved.