org.objectweb.kilim.model.mapping
Class DefaultMappingStrategy

java.lang.Object
  extended byorg.objectweb.kilim.model.mapping.DefaultMappingStrategy
All Implemented Interfaces:
MappingStrategy

public class DefaultMappingStrategy
extends java.lang.Object
implements MappingStrategy

This class is a simple container dedicated to the definition of instanciation strategies. It is used by the component factory to find the instanciation manager to be associated to each application component. It is possible to redefine a default instanciation manager, and to define per template managers and per instance managers. The factory uses the following look up strategy. The search is stopped as soon as a manager is found. the component factory first looks for a manager explicitely associated to the component. If none can be found, it then looks for a manager explicitely associated to the component template. If none can be found, it recursively looks for a manager explicitely associated to super templates. If none can be found it looks for a default manager. No null value can be returned, since this class defines a NAryPreInstanciationMger as default instanciation manager and no null value is accepted by the setDefaultMger().

Author:
horn

Field Summary
private  Mapper defaultMapper
           
private  java.util.HashMap perInstanceMapper
           
private  java.util.HashMap perTemplateMapper
           
 
Constructor Summary
DefaultMappingStrategy()
           
DefaultMappingStrategy(Mapper aMapper)
          Method DefaultMappingStrategy.
 
Method Summary
 Mapper getDefaultMapper()
          Method getDefaultMapper returns the default mapper.
 Mapper getPerInstanceMapper(java.lang.String aName)
          Method getPerInstanceMapper.
 Mapper getPerTemplateMapper(java.lang.String aName)
          Method getPerTemplateMapper
 void setDefaultMapper(Mapper aMapper)
          Method setDefaultMapper.
 void setPerInstanceMapper(java.lang.String aName, Mapper aMapper)
          Method setPerInstanceMger sets the mapper to be used for a given instance.
 void setPerTemplateMapper(java.lang.String aName, Mapper aMapper)
          Method setPerTemplateMapper sets the mapper to be used when the component is an instance of a template or one of its subtemplates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultMapper

private Mapper defaultMapper

perTemplateMapper

private java.util.HashMap perTemplateMapper

perInstanceMapper

private java.util.HashMap perInstanceMapper
Constructor Detail

DefaultMappingStrategy

public DefaultMappingStrategy()
                       throws KilimException
See Also:
Object.Object()

DefaultMappingStrategy

public DefaultMappingStrategy(Mapper aMapper)
                       throws KilimException
Method DefaultMappingStrategy.

Parameters:
aMapper - : a default mapper (this ctor just contains a call to setDefaultMapper(aMapper)
Throws:
KilimException - : generated if the reference is null. A NullMapper should be indicated if no mapping should be performed at runtime.
Method Detail

setDefaultMapper

public void setDefaultMapper(Mapper aMapper)
                      throws KilimException
Description copied from interface: MappingStrategy
Method setDefaultMapper.

Specified by:
setDefaultMapper in interface MappingStrategy
Parameters:
aMapper - : a default mapper (this ctor just contains a call to setDefaultManager(aMapper). This value cannot be null. A NullMapper should be used if no action should be performed at instanciation time.
Throws:
KilimException - : generated if the reference is null.
See Also:
MappingStrategy.setDefaultMapper(Mapper)

getDefaultMapper

public Mapper getDefaultMapper()
Description copied from interface: MappingStrategy
Method getDefaultMapper returns the default mapper.

Specified by:
getDefaultMapper in interface MappingStrategy
Returns:
Mapper
See Also:
MappingStrategy.getDefaultMapper()

setPerTemplateMapper

public void setPerTemplateMapper(java.lang.String aName,
                                 Mapper aMapper)
                          throws KilimException
Description copied from interface: MappingStrategy
Method setPerTemplateMapper sets the mapper to be used when the component is an instance of a template or one of its subtemplates.

Specified by:
setPerTemplateMapper in interface MappingStrategy
Parameters:
aName - is name of the template.
aMapper - is the mapper to be used.
Throws:
KilimException - : generated when aName is null.
See Also:
MappingStrategy.setPerTemplateMapper(String, Mapper)

getPerTemplateMapper

public Mapper getPerTemplateMapper(java.lang.String aName)
                            throws KilimException
Description copied from interface: MappingStrategy
Method getPerTemplateMapper

Specified by:
getPerTemplateMapper in interface MappingStrategy
Parameters:
aName - : the name of the template.
Returns:
Mapper
Throws:
KilimException - : generated when aName is null
See Also:
MappingStrategy.getPerTemplateMapper(String)

setPerInstanceMapper

public void setPerInstanceMapper(java.lang.String aName,
                                 Mapper aMapper)
                          throws KilimException
Description copied from interface: MappingStrategy
Method setPerInstanceMger sets the mapper to be used for a given instance.

Specified by:
setPerInstanceMapper in interface MappingStrategy
Parameters:
aName - : the name of the component.
aMapper - : the mapper to be used
Throws:
KilimException - : generated when aName is null.
See Also:
MappingStrategy.setPerInstanceMapper(String, Mapper)

getPerInstanceMapper

public Mapper getPerInstanceMapper(java.lang.String aName)
                            throws KilimException
Description copied from interface: MappingStrategy
Method getPerInstanceMapper.

Specified by:
getPerInstanceMapper in interface MappingStrategy
Parameters:
aName - : the name of the component
Returns:
Mapper :
Throws:
KilimException - : generated when aName is null.
See Also:
MappingStrategy.getPerInstanceMapper(String)