Search code examples
javaspringcsvapache-cameldozer

how to Mapping Camel Unmarshal CSV to Dozer Bean


Using Camel I am splitting file

<unmarshal>
    <csv delimiter="|"/>
</unmarshal>
<split>
    <simple>${body}</simple> <!-- Body will be a list of lists -->
    <choice>
        <when>
            <simple>${body[0]} == '100'</simple>
            <to uri="bean:processor100"/>
        </when>         
        <when>
            <simple>${body[0]} == '200'</simple>
            <to uri="bean:processor200"/>
        </when>
    </choice>

In each Bean I am writing

public void process(List<String> csvRows) {
object.setcol1(csvRows.get(1));
object.setcol2(csvRows.get(2));
object.setcol3(csvRows.get(3));

I am thinking a way using jxls to externalize the mapping in some mapping file.

Is there any way where I can pull mappings from external source (properties file or XML) & bind directly


Solution

  • Answering own question

    Solved using BeanIO.

    BeanIO mapping XML file which get mappings.