Dear All,
I am working on CSV to Object creation Example with the use of Camel.
I have create a bean in which i have a method with will do all operation,
and that method will return List.
My Question is how i am able to get List outside the Camel.
Source Code:
public class Person {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.firstName + "===" + this.lastName;
}
}
public class UnMarshallingTest {
public static void main(String[] args) throws Exception {
DefaultCamelContext context = new DefaultCamelContext();
// append the routes to the context
context.addRoutes(new UnMarshallingTestRoute());
CSVToPerson csvToPerson = new CSVToPerson();
SimpleRegistry reg = new SimpleRegistry();
reg.put("csvToPerson", csvToPerson);
context.setRegistry(reg);
context.start();
Thread.sleep(3000);
System.out.println("Done");
context.stop();
}
}
public class UnMarshallingTestRoute extends RouteBuilder {
public void configure() throws Exception {
from("file:/home/viral/Projects/camel/cxfJavaTest/src/data?noop=true")
.unmarshal().csv()
.beanRef("csvToPerson", "process");
}
}
public class CSVToPerson {
public List<Person> process(List<List> csvRows) {
List<Person> oList = new ArrayList<Person>();
System.out.println("called");
for (List csvRow : csvRows) {
Person person = new Person();
person.setFirstName((String) csvRow.get(0));
person.setLastName((String) csvRow.get(1));
oList.add(person);
// doSomethingTo(person);
System.out.println("++++++++++++++++++++++++++");
System.out.println(person);
System.out.println("++++++++++++++++++++++++++");
}
System.out.println("End");
return oList;
}
}
I have Only Camel Context Object how i am able to get List from context
Object.
--
View this message in context:
http://camel.465427.n5.nabble.com/unable-to-retrieve-response-from-camel-context-tp5769282.html
Sent from the Camel - Users mailing list archive at Nabble.com.