camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulliard <cmoulli...@gmail.com>
Subject Re: Is there a way to extend marshall method of CsvDataFormat class
Date Thu, 11 Dec 2008 14:40:06 GMT

Maybe we need some kinda endpoint that lets you set arbitrary nested
properties on a bean? e.g. it could take a Map or List of Maps and
make instances of a certain type - then set the properties on the bean
using introspection? I guess its only gonna be useful for taking data
from CSVs; 

>> 1) The best solution would be to have a JANXML api (Java Api for Non XML
>> format : name choosen by opposition to JAXB2) where using annotation in
>> the Java Bean, the mapping between the content of the CSV file and the
>> bean is defined.

>> 2) Without such an api, what you proposes is certainly a good compromise.
>> Because, if this kind of endppoint is not provided, the user will be
>> attempted to by pass the marshall/unmarshall step and to create a
>> proprietary bean making the marhsalling/unmarshalling process using
>> directly the CSV classes of apache CSV or SuperCSV in it.

>> 3) An alternative is that CSV or SuperCSV component become real endpoints
>> and not only dataformat classes

from(file:///myFiletoProcess)
.to(supercsv:BeanToBeUsedToMap:CSVPreferences) --> output = POJO
.to(jms:helloSuperCSV)

Remark : I don't know how smooks is implemented in Camel but this question
is also pertinent for it. 

but who knows maybe this could be useable for other
scenarios, like taking arbitrary JSON or something?

>> Yes. This should be a generic solution to support all sort of scenari.


James.Strachan wrote:
> 
> 2008/12/11 cmoulliard <cmoulliard@gmail.com>:
>> Jaxb is not a good example because here the content of the XML will be
>> mapped
>> to the POJO object directly though the marshall/unmarshall process
>> defined
>> in spring xml config file of camel
> 
> Its a good example in that you are creating a new DataFormat instance
> and using that - thats all I meant.
> 
> 
>> With the marshall/unmarshall method of CSV or SuperCSV, I will receive an
>> array this
>> ArrayList<Map<String, String>>()
>>
>> that I need to map manually to my POJO through an additional step
>>
>> from("file://myCSVfile")
>> .marshal().csv()
>> .bean("bean:mapArrayListtoMyBean")
>> .to("");
>>
>> So JAXB like Xstream have one advantage over implementation of CSV
>> (apache)
>> or SuperCSV ;)
> 
> :)
> 
> Maybe we need some kinda endpoint that lets you set arbitrary nested
> properties on a bean? e.g. it could take a Map or List of Maps and
> make instances of a certain type - then set the properties on the bean
> using introspection? I guess its only gonna be useful for taking data
> from CSVs; but who knows maybe this could be useable for other
> scenarios, like taking arbitrary JSON or something?
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://fusesource.com/
> 
> 


-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/Is-there-a-way-to-extend-marshall-method-of-CsvDataFormat-class-tp20955830s22882p20956660.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message