net.sf.mmm.util.collection.impl
Class CollectionFactoryManagerImpl

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.collection.impl.CollectionFactoryManagerImpl
All Implemented Interfaces:
CollectionFactoryManager

@Singleton
@Named
public class CollectionFactoryManagerImpl
extends AbstractLoggableComponent
implements CollectionFactoryManager

This is the default implementation of the CollectionFactoryManager interface.

Since:
1.0.1
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  Map<Class<? extends Collection>,CollectionFactory> collectionFactoryMap
           
private static CollectionFactoryManager instance
           
private  Map<Class<? extends Map>,MapFactory> mapFactoryMap
           
 
Constructor Summary
CollectionFactoryManagerImpl()
          The constructor.
 
Method Summary
protected  void doInitialize()
          This method performs the actual initialization.
<C extends Collection>
CollectionFactory<C>
getCollectionFactory(Class<C> collectionType)
          This method gets the CollectionFactory for the given collectionType.
static CollectionFactoryManager getInstance()
          This method gets the singleton instance of this CollectionFactoryManager implementation.
<MAP extends Map>
MapFactory
getMapFactory(Class<MAP> mapType)
          This method gets the MapFactory for the given mapType.
protected  CollectionFactory registerCollectionFactory(CollectionFactory factory)
          This method registers the given factory using its collection-interface.
protected
<COLLECTION extends Collection>
CollectionFactory
registerCollectionFactory(CollectionFactory<? extends COLLECTION> factory, Class<COLLECTION> collectionInterface)
          This method registers the given factory for the given collectionInterface.
protected  MapFactory registerMapFactory(MapFactory factory)
          This method registers the given factory using its map-interface.
protected
<MAP extends Map>
MapFactory
registerMapFactory(MapFactory<? extends MAP> factory, Class<MAP> mapInterface)
          This method registers the given factory for the given mapInterface.
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static CollectionFactoryManager instance
See Also:
getInstance()

collectionFactoryMap

private final Map<Class<? extends Collection>,CollectionFactory> collectionFactoryMap
See Also:
getCollectionFactory(Class)

mapFactoryMap

private final Map<Class<? extends Map>,MapFactory> mapFactoryMap
See Also:
getMapFactory(Class)
Constructor Detail

CollectionFactoryManagerImpl

public CollectionFactoryManagerImpl()
The constructor.

Method Detail

doInitialize

protected void doInitialize()
This method performs the actual initialization. It is called when AbstractComponent.initialize() is invoked for the first time.
ATTENTION:
When you override this method from a sub-class you need to do a super.AbstractComponent.doInitialize().

Overrides:
doInitialize in class AbstractLoggableComponent

getInstance

public static CollectionFactoryManager getInstance()
This method gets the singleton instance of this CollectionFactoryManager implementation.
This design is the best compromise between easy access (via this indirection you have direct, static access to all offered functionality) and IoC-style design which allows extension and customization.
For IoC usage, simply ignore all static getInstance() methods and construct new instances via the container-framework of your choice (like plexus, pico, springframework, etc.). To wire up the dependent components everything is properly annotated using common-annotations (JSR-250). If your container does NOT support this, you should consider using a better one.

Returns:
the singleton instance.

getCollectionFactory

public <C extends Collection> CollectionFactory<C> getCollectionFactory(Class<C> collectionType)
This method gets the CollectionFactory for the given collectionType.

Specified by:
getCollectionFactory in interface CollectionFactoryManager
Type Parameters:
C - is the generic type of the Collection.
Parameters:
collectionType - is the type of the Collection. This should be the Collection interface such as List.class.
Returns:
the CollectionFactory for the given collectionType. The collectionType has to be assignable from CollectionFactory.getCollectionInterface() of the returned instance. Typically it will be equal.

getMapFactory

public <MAP extends Map> MapFactory getMapFactory(Class<MAP> mapType)
This method gets the MapFactory for the given mapType.

Specified by:
getMapFactory in interface CollectionFactoryManager
Type Parameters:
MAP - is the generic type of the Map.
Parameters:
mapType - is the type of the Map. This should be the interface such as Map.class or SortedMap.class.
Returns:
the MapFactory for the given mapType. The mapType has to be assignable from MapFactory.getMapInterface() of the returned instance. Typically it will be equal.

registerMapFactory

protected MapFactory registerMapFactory(MapFactory factory)
This method registers the given factory using its map-interface.

Parameters:
factory - is the MapFactory to register.
Returns:
the MapFactory that has been replaced with factory or null if none was replaced.
See Also:
registerMapFactory(MapFactory, Class)

registerMapFactory

protected <MAP extends Map> MapFactory registerMapFactory(MapFactory<? extends MAP> factory,
                                                          Class<MAP> mapInterface)
This method registers the given factory for the given mapInterface.

Type Parameters:
MAP - is the generic type of the mapInterface.
Parameters:
factory - is the MapFactory to register.
mapInterface - is the interface of the associated Map. It has to be assignable from the map-interface of the given factory.
Returns:
the MapFactory that was registered for the given mapInterface before and has now been replaced with factory or null if none was replaced.

registerCollectionFactory

protected CollectionFactory registerCollectionFactory(CollectionFactory factory)
This method registers the given factory using its collection-interface.

Parameters:
factory - is the CollectionFactory to register.
Returns:
the CollectionFactory that has been replaced with factory or null if none was replaced.
See Also:
registerCollectionFactory(CollectionFactory, Class)

registerCollectionFactory

protected <COLLECTION extends Collection> CollectionFactory registerCollectionFactory(CollectionFactory<? extends COLLECTION> factory,
                                                                                      Class<COLLECTION> collectionInterface)
This method registers the given factory for the given collectionInterface.

Type Parameters:
COLLECTION - is the generic type of the collectionInterface.
Parameters:
factory - is the CollectionFactory to register.
collectionInterface - is the interface of the associated Collection. It has to be assignable from the collection-interface of the given factory.
Returns:
the CollectionFactory that was registered for the given collectionInterface before and has now been replaced with factory or null if none was replaced.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.