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

java.lang.Object
  extended by org.clazzes.util.lifecycle.impl.AbstractObjectFactoryImpl<T>
      extended by org.clazzes.util.lifecycle.impl.AbstractRecyclerImpl<T>
Type Parameters:
T - The type of key used for the factory.
All Implemented Interfaces:
ObjectFactory<T>, Recycler<T>
Direct Known Subclasses:
ReflectionRecycler

public abstract class AbstractRecyclerImpl<T>
extends AbstractObjectFactoryImpl<T>
implements Recycler<T>

Abstract base class of type Recycler using lists of WeakReferencees to cache recycled objects.

Author:
rbreuss

Constructor Summary
protected AbstractRecyclerImpl()
           
 
Method Summary
 ObjectCreatable<T> get(T key)
          Deliver an object for the passed key.
protected  ObjectCreatable<T> internalCreateNew(T key)
          Concrete implementations should use this method instead of AbstractObjectFactoryImpl.createNew(Object) to retrieve new objects.
protected  boolean isCachable(T key, ObjectCreatable<T> obj)
          Checks if the passed object and key are valid, and the object can be recycled.
 void pushBack(T key, ObjectCreatable<T> obj)
          Objects implementing the Recyclable interface must call this method in their Recyclable.recycle() method with themselves and their key as arguments, to return themselves to the Recycler.
 
Methods inherited from class org.clazzes.util.lifecycle.impl.AbstractObjectFactoryImpl
createNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRecyclerImpl

protected AbstractRecyclerImpl()
Method Detail

get

public ObjectCreatable<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.

pushBack

public void pushBack(T key,
                     ObjectCreatable<T> obj)
Description copied from interface: Recycler
Objects implementing the Recyclable interface must call this method in their Recyclable.recycle() method with themselves and their key as arguments, to return themselves to the Recycler.

Specified by:
pushBack in interface Recycler<T>
Parameters:
key - the key by which the Recyclable should be identified to the Recycler
obj - the object which is to be recycled.

isCachable

protected boolean isCachable(T key,
                             ObjectCreatable<T> obj)
Checks if the passed object and key are valid, and the object can be recycled.

Parameters:
key -
obj -
Returns:

internalCreateNew

protected ObjectCreatable<T> internalCreateNew(T key)
Description copied from class: AbstractObjectFactoryImpl
Concrete implementations should use this method instead of AbstractObjectFactoryImpl.createNew(Object) to retrieve new objects.

Overrides:
internalCreateNew in class AbstractObjectFactoryImpl<T>
Parameters:
key - the key describing the object
Returns:
a object identified by key.


Copyright © 2010. All Rights Reserved.