On Fri, Jul 1, 2011 at 10:50 AM, Gnanaguru S
<gnanaguru.sattanat...@wipro.com> wrote:
>
> Hi Claus,
>
> Thanks. I will look into it. Let have this code
>
> <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
>      <route>
>        <from uri="file://inputdir/"/>
>        <log message="Moving ${file:name} to the output directory"/>
>        <to uri="file://outputdir/"/>
>      </route>
>    </camelContext>
>
> I want to modify to the above code, such that i can read the contents of a
> file. By the way it will be much helpful for me understand . Since i am new
> to this arena.
>
> Where are the description for route,from,to,log and all. What are the other
> things available, with which i can read the contents of a file and also
> other operations. Help me out.
>

What do you want to do with the file? You say read the content. Do you
want to read it from some Java code?
If so you can use regular java beans with Camel.

        <from uri="file://inputdir/"/>
        <log message="Moving ${file:name} to the output directory"/>
        <to uri="bean:myBean?method=myMethod"/>
        <to uri="file://outputdir/"/>

And then define a bean with the id myBean, outside the <camelContext> tag

<bean id="myBean" class="com.foo.MyBean"/>

And then your bean implementation is like

public class MyBean {

public String myMethod(String content) {
   // here you can do whatever you want with the file content.
   // and if you want to change the message, just return whatever, such as:
   return "Hey I read the content of the file which is: " + content;
}


You can read more about using beans with Camel
http://camel.apache.org/bean-integration.html




>
> Cheers
> Guru
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/File-Reading-Writing-using-Camel-tp4541266p4541417.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to