Menu

Multiple dozerBeanMapping.xml files

Help
srkirkby
2006-03-07
2021-09-08
  • srkirkby

    srkirkby - 2006-03-07

    We have a project that will map approx. 20 legacy beans to 17 domain classes. As such, the dozerBeanMapping.xml will bocome somewhat unweildy. It is possible to have more than one dozerBeanMapping.xml file, named along the following lines:

    dozerBeanMapping-legacyClassA.xml
    dozerBeanMapping-legacyClassB.xml
    dozerBeanMapping-legacyClassC.xml
    etc...

    Thanks

     
    • Franz Garsombke

      Franz Garsombke - 2006-03-07

      Using injection you can set any number of mapping files:

      http://dozer.sourceforge.net/documentation/usage.html

      <bean id="net.sf.dozer.util.mapping.MapperIF"
        class="net.sf.dozer.util.mapping.DozerBeanMapper" singleton="true">
        <property name="mappingFiles">
          <list>
            <value>dozerBeanMapping.xml</value>
            <value>someOtherDozerBeanMappings.xml</value>
          </list>
        </property>
      </bean>

      You can also do this programatically:

      List myMappingFiles = new ArrayList();
      myMappingFiles.add("dozerBeanMapping.xml");
      myMappingFiles.add("someOtherDozerBeanMappings.xml");
      DozerBeanMapper mapper = new DozerBeanMapper();
      mapper.setMappingFiles(myMappingFiles);
      DestinationObject destObject = (DestinationObject) mapper.map(sourceObject, DestinationObject.class);
               

      Thanks for looking.

      Franz

       
      • watchuta awkin

        watchuta awkin - 2021-09-08

        wow! ok, can import like this be done across multiple "shared" projects/libraries?
        example if i have proj1.war & proj2.war that each has it's own dozerbeanmapping.xml for classes known explicitly to themselves only...
        and they reference or call shared1.jar through remote EJB which has a dozerbeanmapping.xml of its' own.
        currently we have found we need to copy mappings from shared1.jar's dozerbeanmapping.xml and paste into the wars, else we get error that no mapping exists.
        This is issue because if 1 mapping changes in the jar, now we have to edit all the wars to have that change which is a lot of additional effort which I'm sure can be avoided but I do not discover how as yet. please tell?

         

Log in to post a comment.