Configure custom converters using Dozer Java API

Go To StackoverFlow.com

7


I am trying to use Dozer Java API to map two java classes using a custom converter. Is there a way I can configure class-level custom converters in Java? Right now I have to add the configuration in XML:

<configuration>
    <custom-converters>
        <converter type="com.abc.A2BConverter" >
            <class-a>com.abc.ClassA</class-a>
            <class-b>com.abc.ClassB</class-b>
      </converter>
    </custom-converters>     
</configuration>`

Any help is appreciated!

2012-04-05 18:27
by dchen
Maybe using the addMapping() method from DozerBeanMapper (http://dozer.sourceforge.net/apidocs/org/dozer/DozerBeanMapper.html - ndeverge 2012-04-05 19:19
Thank you for your reply, nico_ekito. However I haven't found a way to configure class/type level custom converter using the addMapping() method. The customConverter interface does not exist in TypeMappingBuilder or DozerBuilder.MappingBuilder; it is in FieldMappingBuilder - dchen 2012-04-06 14:43


7

The Dozer documentation says:

In fact some parts of the configuration (e.g. global configuration block) are only possible to express in Xml format. (Link)

As far as I know class-level custom converters have to be defined in this global configuration block.

So: No, you cannot define them via the Java API.

2012-04-16 11:18
by Sebi
Thank you for your help - dchen 2012-04-18 15:32
You're welcome - Sebi 2012-04-18 15:41
Ads