Hi All,
i am trying my hands on camel where i have to fetch some csv file from a
file system and needs to convert it to xml format and place it on some other
system
i am using camel for this and here is my sample POC code
*import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import com.poc.convertor.CSVConverterBean;
public class TestPOC {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:data/csv?noop=true").unmarshal().csv().bean(new
CSVConverterBean(),"processCSVInvoice").to("file:data/csvoutput?fileName=test.xml").marshal("jaxb");
}
});
context.start();
Thread.sleep(1000);
context.stop();
}
}*
In this approach camel csv unmarshaller will covert the csv file in to java
list List<List<String>> i have written a java converter
CSVConverterBeanwhich will iterate the list and set the values in the
respective java
objects being generated by jaxb 2.x , final object is being marshaled in to
xml and file is being saved.
Everything is being working properly with only one issue , if in future
there arises any request to change mapping we need to do the modification in
CSVConverterBean and than this java file needs to be recompiled and need to
be redistributed which we want to avoid.
my question is, Is there any way by which we can map the values from the
java List being given by Camel to the respective java classes being
generated by the JaxB so that the need to recompile java code can be
avoided.
Thanks in advance for the help