org.dozer
Class DozerBeanMapper

java.lang.Object
  extended by org.dozer.DozerBeanMapper
All Implemented Interfaces:
Mapper

public class DozerBeanMapper
extends Object
implements Mapper

Public Dozer Mapper implementation. This should be used/defined as a singleton within your application. This class perfoms several one time initializations and loads the custom xml mappings, so you will not want to create many instances of it for performance reasons. Typically a system will only have one DozerBeanMapper instance per VM. If you are using an IOC framework (i.e Spring), define the Mapper as singleton="true". If you are not using an IOC framework, a DozerBeanMapperSingletonWrapper convenience class has been provided in the Dozer jar.

It is technically possible to have multiple DozerBeanMapper instances initialized, but it will hinder internal performance optimizations such as caching.

Author:
tierney.matt, garsombke.franz, dmitry.buzdin

Constructor Summary
DozerBeanMapper()
           
DozerBeanMapper(List<String> mappingFiles)
           
 
Method Summary
 void addMapping(BeanMappingBuilder mappingBuilder)
           
 void destroy()
           
 List<CustomConverter> getCustomConverters()
           
 Map<String,CustomConverter> getCustomConvertersWithId()
           
 CustomFieldMapper getCustomFieldMapper()
           
 List<? extends DozerEventListener> getEventListeners()
           
 List<String> getMappingFiles()
          Returns list of provided mapping file URLs
protected  Mapper getMappingProcessor()
           
<T> T
map(Object source, Class<T> destinationClass)
          Constructs new instance of destinationClass and performs mapping between from source
<T> T
map(Object source, Class<T> destinationClass, String mapId)
          Constructs new instance of destinationClass and performs mapping between from source
 void map(Object source, Object destination)
          Performs mapping between source and destination objects
 void map(Object source, Object destination, String mapId)
          Performs mapping between source and destination objects
 void setCustomConverters(List<CustomConverter> customConverters)
           
 void setCustomConvertersWithId(Map<String,CustomConverter> customConvertersWithId)
          Converters passed with this method could be further referenced in mappings via its unique id.
 void setCustomFieldMapper(CustomFieldMapper customFieldMapper)
           
 void setEventListeners(List<? extends DozerEventListener> eventListeners)
           
 void setFactories(Map<String,BeanFactory> factories)
           
 void setMappingFiles(List<String> mappingFileUrls)
          Sets list of URLs for custom XML mapping files, which are loaded when mapper gets initialized.
 void setMappings(List<? extends BeanMappingBuilder> mappingBuilder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DozerBeanMapper

public DozerBeanMapper()

DozerBeanMapper

public DozerBeanMapper(List<String> mappingFiles)
Method Detail

map

public void map(Object source,
                Object destination,
                String mapId)
         throws MappingException
Performs mapping between source and destination objects

Specified by:
map in interface Mapper
Throws:
MappingException

map

public <T> T map(Object source,
                 Class<T> destinationClass,
                 String mapId)
      throws MappingException
Constructs new instance of destinationClass and performs mapping between from source

Specified by:
map in interface Mapper
Returns:
Throws:
MappingException

map

public <T> T map(Object source,
                 Class<T> destinationClass)
      throws MappingException
Constructs new instance of destinationClass and performs mapping between from source

Specified by:
map in interface Mapper
Returns:
Throws:
MappingException

map

public void map(Object source,
                Object destination)
         throws MappingException
Performs mapping between source and destination objects

Specified by:
map in interface Mapper
Throws:
MappingException

getMappingFiles

public List<String> getMappingFiles()
Returns list of provided mapping file URLs

Returns:
unmodifiable list of mapping files

setMappingFiles

public void setMappingFiles(List<String> mappingFileUrls)
Sets list of URLs for custom XML mapping files, which are loaded when mapper gets initialized. It is possible to load files from file system via file: prefix. If no prefix is given mapping files are loaded from classpath and can be packaged along with the application.

Parameters:
mappingFileUrls - URLs referencing custom mapping files
See Also:
URL

setFactories

public void setFactories(Map<String,BeanFactory> factories)

setCustomConverters

public void setCustomConverters(List<CustomConverter> customConverters)

getCustomConverters

public List<CustomConverter> getCustomConverters()

getCustomConvertersWithId

public Map<String,CustomConverter> getCustomConvertersWithId()

destroy

public void destroy()

getMappingProcessor

protected Mapper getMappingProcessor()

setMappings

public void setMappings(List<? extends BeanMappingBuilder> mappingBuilder)

addMapping

public void addMapping(BeanMappingBuilder mappingBuilder)

getEventListeners

public List<? extends DozerEventListener> getEventListeners()

setEventListeners

public void setEventListeners(List<? extends DozerEventListener> eventListeners)

getCustomFieldMapper

public CustomFieldMapper getCustomFieldMapper()

setCustomFieldMapper

public void setCustomFieldMapper(CustomFieldMapper customFieldMapper)

setCustomConvertersWithId

public void setCustomConvertersWithId(Map<String,CustomConverter> customConvertersWithId)
Converters passed with this method could be further referenced in mappings via its unique id. Converter instances passed that way are considered stateful and will not be initialized for each mapping.

Parameters:
customConvertersWithId - converter id to converter instance map


Copyright © 2005-2011 dozer. All Rights Reserved.