[ 
https://issues.apache.org/jira/browse/CAMEL-12207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16343469#comment-16343469
 ] 

abccbaandy edited comment on CAMEL-12207 at 1/29/18 3:15 PM:
-------------------------------------------------------------

Hi, I'm not sure I understand your response. In fact, I already create one for 
my project.

like this:

 converter
{code:java}
@Converter
 public List<String> GenericFiletoListString(GenericFile file, Exchange 
exchange) throws IOException {
    String raw = 
exchange.getContext().getTypeConverter().convertTo(String.class, file);
    StringReader stringReader = 
exchange.getContext().getTypeConverter().convertTo(StringReader.class, raw);
    List<String> list = IOUtils.readLines(stringReader);
     return list;
}
{code}
bean processor
{code:java}
public void process(List<String> list) {
    log.info("process : {}", list);
}{code}
 router
{code:java}
from("file://......").bean(fileHandler, "process");
{code}
 

Those code work well without any warning or error(from IDEA,compiler or maven).

 

Why type erasure affect my issue here?

Or it just bad practice to write code like these.


was (Author: abccbaandy):
Hi, I'm not sure I understand your response. In fact, I already create one for 
my project.

like this:

 converter
{code:java}
@Converter
 public List<String> GenericFiletoListString(GenericFile file, Exchange 
exchange) throws IOException {
    String raw = 
exchange.getContext().getTypeConverter().convertTo(String.class, file);
    StringReader stringReader = 
exchange.getContext().getTypeConverter().convertTo(StringReader.class, raw);
    List<String> list = IOUtils.readLines(stringReader);
     return list;
}


{code}
bean processor
{code:java}
public void process(List<String> list) {
    log.info("process : {}", list);
}{code}
 router
{code:java}
from("file://......").bean(fileHandler, "process");
{code}
 

Those code work well without any warning or error(from IDEA,compiler or maven).

 

Why type erasure affect my issue here?

Or it just bad practice to write code like these.

> Support new TypeConverter to convert GenericFile to List<String>
> ----------------------------------------------------------------
>
>                 Key: CAMEL-12207
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12207
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.20.1
>            Reporter: abccbaandy
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> I think it's useful when we need process files from File or FTP component.
> Currently TypeConverter only support GenericFile to String, and we need 
> convert it by ourselves.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to