Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:41:37+00:00 2026-05-20T18:41:37+00:00

I have looked at the Dozer’s FAQs and docs, including the SourceForge forum, but

  • 0

I have looked at the Dozer’s FAQs and docs, including the SourceForge forum, but I didn’t see any good tutorial or even a simple example on how to implement a custom BeanFactory.

Everyone says, “Just implement a BeanFactory”. How exactly do you implement it?

I’ve Googled and all I see are just jars and sources of jars.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:41:37+00:00Added an answer on May 20, 2026 at 6:41 pm

    Here is one of my BeanFactories, I hope it helps to explain the common pattern:

    public class LineBeanFactory implements BeanFactory {
    
        @Override
        public Object createBean(final Object source, final Class<?> sourceClass, final String targetBeanId) {
    
            final LineDto dto = (LineDto) source;
    
            return new Line(dto.getCode(), dto.getElectrified(), dto.getName());
    
        }
    
    }
    

    And the corresponding XML mapping:

    <mapping>
    
            <class-a bean-factory="com.floyd.nav.web.ws.mapping.dozer.LineBeanFactory">com.floyd.nav.core.model.Line</class-a>
            <class-b>com.floyd.nav.web.contract.dto.LineDto</class-b>
    
    </mapping>
    

    This way I declare that when a new instance of Line is needed then it should create it with my BeanFactory. Here is a unit test, that can explain it:

    @Test
    public void Line_is_created_with_three_arg_constructor_from_LineDto() {
    
        final LineDto dto = createTransientLineDto();
    
        final Line line = (Line) this.lineBeanFactory.createBean(dto, LineDto.class, null);
    
        assertEquals(dto.getCode(), line.getCode());
        assertEquals(dto.getElectrified(), line.isElectrified());
        assertEquals(dto.getName(), line.getName());
    
    }
    

    So Object source is the source bean that is mapped, Class sourceClass is the class of the source bean (I’m ignoring it, ’cause it will always be a LineDto instance). String targetBeanId is the ID of the destination bean (too ignored).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked and tried but don't see where I can stop some being
I have looked at the Suggested related questions but none of them are what
Have looked so long for a library specialized in dealing with iPhone Accelerometer but
I have looked on here and found a few examples but nothing works so
I have looked at all the other answers to this question, but none of
I have looked and thought about good and bad points of my past designs
I have looked everywhere but couldn't find it anywhere. I installed it successfully but
I have looked around, but I have been unable to figure this out, some
I have looked at similar questions on Stack Overflow but haven't been able to
I have looked at similar queries here, but I can't seem to apply them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.