no.sesat.search.site
Class AbstractSiteKeyedFactory

java.lang.Object
  extended by no.sesat.search.site.AbstractSiteKeyedFactory
All Implemented Interfaces:
SiteKeyedFactory

public abstract class AbstractSiteKeyedFactory
extends Object
implements SiteKeyedFactory

Abstract implementation of a SiteKeyedFactory to help with the INSTANCES map and locking pattern typically used around it using ReentrantReadWriteLocks.

Version:
$Id: AbstractSiteKeyedFactory.java 7225 2009-04-09 00:32:20Z ssmiweve $

Nested Class Summary
protected static interface AbstractSiteKeyedFactory.FactoryConstructor<T extends AbstractSiteKeyedFactory>
          Wraps a constructor so that it may be delegated to from the instanceOf method.
 
Constructor Summary
protected AbstractSiteKeyedFactory()
           
 
Method Summary
protected static
<T extends AbstractSiteKeyedFactory>
T
instanceOf(Site site, Map<Site,T> instances, ReentrantReadWriteLock instancesLock, AbstractSiteKeyedFactory.FactoryConstructor<T> constructor)
          Handles the locking pattern around the INSTANCES map that's done with a ReentrantReadWriteLock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface no.sesat.search.site.SiteKeyedFactory
remove
 

Constructor Detail

AbstractSiteKeyedFactory

protected AbstractSiteKeyedFactory()
Method Detail

instanceOf

protected static final <T extends AbstractSiteKeyedFactory> T instanceOf(Site site,
                                                                         Map<Site,T> instances,
                                                                         ReentrantReadWriteLock instancesLock,
                                                                         AbstractSiteKeyedFactory.FactoryConstructor<T> constructor)
Handles the locking pattern around the INSTANCES map that's done with a ReentrantReadWriteLock.

Type Parameters:
T - the type of SiteKeyedFactory that can be constructed.
Parameters:
site - the site this factory will answer to.
instances - the map of factories of type T already in existence.
instancesLock - the lock used around the instances map
constructor - the wrapper around the constructor used to create factories of type T.
Returns:
the singleton instance of factory of type T related to the given site.
See Also:
http://permalink.gmane.org/gmane.comp.java.sesat.kernel.devel/228


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.