net.sf.seaf.factory.impl
Class CachingFactory

java.lang.Object
  extended by net.sf.seaf.factory.impl.support.DelegatingFactoryBase
      extended by net.sf.seaf.factory.impl.CachingFactory
All Implemented Interfaces:
Factory

public class CachingFactory
extends DelegatingFactoryBase
implements Factory

Factory that caches object instances.

On each request, if an instance of the requested type has already been cached, returns the cached instance as is. Otherwise delegates its instantiation to a supplied instantiating factory, caches the newly created instance for further requests and returns it.


Constructor Summary
CachingFactory()
          Default empty constructor.
CachingFactory(Factory instantiatingFactory)
          Full constructor.
 
Method Summary
<Type> Type
getInstanceOf(Class<Type> type)
          Return an initialized instance of the specified type.
 
Methods inherited from class net.sf.seaf.factory.impl.support.DelegatingFactoryBase
getInstantiatingFactory, setInstantiatingFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingFactory

public CachingFactory()
Default empty constructor. The instantiating factory must be supplied via its setter method.


CachingFactory

public CachingFactory(Factory instantiatingFactory)
Full constructor.

Parameters:
instantiatingFactory - The instantiating factory
Method Detail

getInstanceOf

public final <Type> Type getInstanceOf(Class<Type> type)
Description copied from interface: Factory
Return an initialized instance of the specified type.

Specified by:
getInstanceOf in interface Factory
Parameters:
type - The type of the requested instance
Returns:
The instance


Copyright © 2008-2012 SEAF. All Rights Reserved.