Menu

Dozer 1.5 Roadmap - Spring Integration + more

2005-08-23
2013-05-02
  • Franz Garsombke

    Franz Garsombke - 2005-08-23

    Dozer 1.5 should be released next week. Our short term plan is:

    1. Ability to use as static or non-static (for example a Spring Bean)
    2. Refactoring field-method functionality
    3. Fixing a couple of outstanding bugs

    Does anyone want to see anything else?

    BTW - We have had a volunteer to create an eclipse plugin. I will let you know the status of that as it moves forward.

    Your suggestions are always appreciated.

    Franz

     
    • Richard Lemesle

      Richard Lemesle - 2005-08-23

      Hi,

      We are using Dozer in web applications and we need to put dozer.jar in every web application to allow separate mapping files for each application...

      It would be good to remove the static initializer of the Map class and to replace it with API like these :

      registerMappingFile(URL mappingFileUrl)
      registerMappingFile(URL mappingFileUrl, Classloader classloadForMappingFileAndClasses)
      unregisterMappingFile(URL mappingFileUrl)

      This would allow putting dozer.jar in an external directory.

      Richard.

       
      • Franz Garsombke

        Franz Garsombke - 2005-08-23

        By moving to a static/non-static model we will allow for exactly that. You will be able to 'inject' the config files through the use of a IOC container or add them programatically. This will allow for multiple instances of the BeanMapper as well as only having the jar in an external directory.

        We will still support the static route if users prefer that mode of mapping.

        Thanks for your input.

        Franz

         
    • Matt Tierney

      Matt Tierney - 2005-08-26

      The non-static implementation of the dozer mapper has been successfully added to the dozer code base. This will be available with the upcoming 1.5 release. There have been several requests for this functionality. Below is an example of how it could be used within Spring. The injection of mapping files can also be done programatically via setMappingFiles()

      <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>
          </list>
        </property>
      </bean>

       
    • Richard Lemesle

      Richard Lemesle - 2005-08-29

      Hi,

      When do the 1.5 release will be available ?

      It's a very awaited one ;-)

      Richard.

       
      • Franz Garsombke

        Franz Garsombke - 2005-08-29

        I'm shooting for Wednesday. We have all the Spring stuff done (easy part). Just trying to fix defect 1264347 and one other defect.

        If we can't fix those in time I might just put out 1.5 and then fix those two bugs in patch since I don't think they are utilized that much.

        Thanks,

        Franz

         
    • Richard Lemesle

      Richard Lemesle - 2005-08-29

      Good news ;-)

      Richard.

       
    • Franz Garsombke

      Franz Garsombke - 2005-08-31

      I put out the 1.5 release w/ Spring integration and the ability to use non-static instances.

      Please let us know if there are any problems.

      Thanks,

      Franz

       
    • seb

      seb - 2005-08-31

      Hi again !

      Is it possible to use Dozer on a non-static way without Spring ?
      I want to use Dozer on different WebApps, and to put dozer.jar on a common project (with all my needed jars). But if i do so, i always got the same message :

      Error in loading dozer mapping file: dozerBeanMapping.xml : net.sf.dozer.util.mapping.MappingException: org.xml.sax.SAXException: unable to add 'classA' to <mapping> due to the following exception:
      >>>--- Begin Exception ---<<<
      java.lang.ClassNotFoundException: fr.test.mapping.dozer.A
          at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
          at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java(Compiled Code))
          at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
          at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
          at java.lang.Class.forName1(Native Method)
          at java.lang.Class.forName(Class.java(Compiled Code))
          at net.sf.dozer.util.mapping.fieldmap.ClassMap.setSourceName(ClassMap.java:100)

      Any idea ?
      I really want to use Dozer on a non static way :-)

      Bye
      Seb

       
      • Franz Garsombke

        Franz Garsombke - 2005-08-31

        Hey Seb:

        You can use it without Spring like this:

        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);
                 
        I don't recommend this unless you use a singleton in front of it since we reload all the mapping files.

        Here are the scenarios that I have tested with our container:

        Scenario1 : Does not work - Dozer classloader can not see classes in webapp. I would love to fix this...although I can't seem to figure this one out.

        EAR
          -- APP/INF-LIB
               dozer-full.jar
          -- APP/INF-CLASSES

          WAR 1
            --WEB-INF/LIB
              mymappedclasses.jar
            -- WEB-INF/CLASSES
              dozerMappingFile.xml

        WAR 2
            --WEB-INF/LIB
              mymappedclasses2.jar
            -- WEB-INF/CLASSES
              dozerMappingFile2.xml

        Scenario2 : Works.

        EAR
          -- APP/INF-LIB
          -- APP/INF-CLASSES

          WAR 1
            --WEB-INF/LIB
              mymappedclasses.jar
              dozer-full.jar

            -- WEB-INF/CLASSES
              dozerMappingFile.xml

        WAR 2
            --WEB-INF/LIB
              mymappedclasses2.jar
              dozer-full.jar

            -- WEB-INF/CLASSES
              dozerMappingFile2.xml

        Scenario3 : Works:

        EAR
          -- APP/INF-LIB
              dozer-full.jar
              mymappedclasses.jar
              mymappedclasses2.jar
          -- APP/INF-CLASSES
             oneDozerMappingFileForEverything.xml

          WAR 1
            --WEB-INF/LIB
            -- WEB-INF/CLASSES

        WAR 2
            --WEB-INF/LIB
            -- WEB-INF/CLASSES

        Thanks,

        Franz

         
        • Richard Lemesle

          Richard Lemesle - 2005-08-31

          Hi,

          Our scenario is your first one and I understand that it can't work without specifying the classloaders to use...

          The only way to make it working is to have a method on the mapper to set the classloader  :

          mapper.setMappingFiles(myMappingFiles);
          mapper.setClassload(myClassloader);

          BUT, this means there is only one classloader for all ressource mappings and classes and this will NOT make your scenario 1 working if you are using only one instance of the mapper class ;-)

          You need an API like that :

          mapper.setMappingFile(String mappingFileName, Classloader classloaderToUse)

          Then, each webapp can specify to the mapper its mappingFileName and the corresponding classloader .

          The mappingFile will be loaded using the classloaderToUse AND this classloader will also be used to instantiate classes referenced in this mapping file.

          I think this would work...

          Richard.

           
          • Franz Garsombke

            Franz Garsombke - 2005-08-31

            Richard -

            I will test this. If it works I will put it out today since this is definitely the route we want to take.

            Franz

             
    • Franz Garsombke

      Franz Garsombke - 2005-08-31

      Ok. This is *FINALLY* fixed. This now works:

      EAR
      -- APP/INF-LIB
      dozer-full.jar
      -- APP/INF-CLASSES

      WAR 1
      --WEB-INF/LIB
      mymappedclasses.jar
      -- WEB-INF/CLASSES
      dozerMappingFile.xml

      WAR 2
      --WEB-INF/LIB
      mymappedclasses2.jar
      -- WEB-INF/CLASSES
      dozerMappingFile2.xml

      It was not the ClassLoader used by Castor...but the ClassLoader we were using in our ClassMap:

      This is what tripped us up:

          public void setSourceName(String sourceName) throws ClassNotFoundException {
              this.sourceName = sourceName;
              sourceClass = Class.forName(sourceName);
          }

      This now works:

          public void setSourceName(String sourceName) throws ClassNotFoundException {
              this.sourceName = sourceName;
              sourceClass = Thread.currentThread().getContextClassLoader().loadClass(sourceName);
          }

      The code I used to test:

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

      I will release this as 1.5.0.1 today.

       
      • Richard Lemesle

        Richard Lemesle - 2005-08-31

        Hi,

        Good news ;-)

        And I was wrong, you don't need to store the classloader with each mapping file since you can use the current thread classloader during each mapping operation.

        The current thread classloader will logically always be able to locate the classes we are trying to map ;-)

        Sorry to have indicated you a wrong direction for this bug...

        Richard

         
        • Franz Garsombke

          Franz Garsombke - 2005-08-31

          *Finally* figured that out :)

          1.5.0.1 should work for you. Now you can have as many instances as you want :)

           
    • seb

      seb - 2005-09-01

      Hi !

      Well, the 1.5.0.1 release work, ... but not for me :-)
      No, it just doesn't work when i use sourceTypeHint / destinationTypeHint for a List type field. You just need to change Class.forName() to Thread.currentThread().getContextClassLoader().loadClass() in the following classes :

      net.sf.dozer.util.mapping.fieldmap.Hint --> line 36
      net.sf.dozer.util.mapping.MappingProcessor --> line 357
      net.sf.dozer.util.mapping.converters.CustomConverterContainer --> line 53

      And now it always works for me 8-)

      Bye
      Seb

       
      • Franz Garsombke

        Franz Garsombke - 2005-09-01

        Bullocks. I need to have a full suite of tests we run in a container. Oh well, thanks Seb and I will apply these patches.

        Franz

         

Log in to post a comment.