You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jamie Archibald <ja...@gmail.com> on 2013/09/21 23:34:15 UTC

Custom object renders for simple expression language?

I'm wondering if camel supports custom object renders (similar to log4j)
when doing the simple expression language? Currently it appears it just
calls toString() on the object

for example.

.log("Hello World ${body}");


Rather than calling ${body}.toString() I would like to have it call some
external bean that knows how to render the object.

For example

MyCustomRenderer implement ICamelObjectRenderer {

    public String render(MyObject obj)
     {
           return obj.getName() + obj.getPhoneNumber();
     }
}



-- 
Jamie

Re: Custom object renders for simple expression language?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You have a special use case where using something else than a
scripting language is better, such as a custom bean / processor. Or
implement your own language where you can extend another language if
you really wanna go down that path. Or take a look at what some of the
template libraries like freemarker, velocity can offer.

We should be careful not to add extensions / new functionality in
camel-core when just a single person has a special use-case.




On Sun, Sep 22, 2013 at 5:03 AM, Jamie Archibald <ja...@gmail.com> wrote:
> Thanks. I've been using custom processors for a while however it adds a lot
> of unnecessary code which would be nice to have built in.
>
> Is it possible to submit feature requests or submit code that would provide
> this capability?
>
> Cheers
>
>
>
> On Saturday, September 21, 2013, Willem jiang wrote:
>
>> I'm afraid current Camel doesn't implement this feature.
>> If you want to render the object as you want, I suggest you to write a
>> customer process for your object.
>>
>>
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
>> (English)
>>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>>
>> On Sunday, September 22, 2013 at 5:34 AM, Jamie Archibald wrote:
>>
>> > I'm wondering if camel supports custom object renders (similar to log4j)
>> > when doing the simple expression language? Currently it appears it just
>> > calls toString() on the object
>> >
>> > for example.
>> >
>> > .log("Hello World ${body}");
>> >
>> >
>> > Rather than calling ${body}.toString() I would like to have it call some
>> > external bean that knows how to render the object.
>> >
>> > For example
>> >
>> > MyCustomRenderer implement ICamelObjectRenderer {
>> >
>> > public String render(MyObject obj)
>> > {
>> > return obj.getName() + obj.getPhoneNumber();
>> > }
>> > }
>> >
>> >
>> >
>> > --
>> > Jamie
>>
>>
>>
>>
>
> --
> Jamie



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Custom object renders for simple expression language?

Posted by Jamie Archibald <ja...@gmail.com>.
Thanks. I've been using custom processors for a while however it adds a lot
of unnecessary code which would be nice to have built in.

Is it possible to submit feature requests or submit code that would provide
this capability?

Cheers



On Saturday, September 21, 2013, Willem jiang wrote:

> I'm afraid current Camel doesn't implement this feature.
> If you want to render the object as you want, I suggest you to write a
> customer process for your object.
>
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
> On Sunday, September 22, 2013 at 5:34 AM, Jamie Archibald wrote:
>
> > I'm wondering if camel supports custom object renders (similar to log4j)
> > when doing the simple expression language? Currently it appears it just
> > calls toString() on the object
> >
> > for example.
> >
> > .log("Hello World ${body}");
> >
> >
> > Rather than calling ${body}.toString() I would like to have it call some
> > external bean that knows how to render the object.
> >
> > For example
> >
> > MyCustomRenderer implement ICamelObjectRenderer {
> >
> > public String render(MyObject obj)
> > {
> > return obj.getName() + obj.getPhoneNumber();
> > }
> > }
> >
> >
> >
> > --
> > Jamie
>
>
>
>

-- 
Jamie

Re: Custom object renders for simple expression language?

Posted by Willem jiang <wi...@gmail.com>.
I'm afraid current Camel doesn't implement this feature.
If you want to render the object as you want, I suggest you to write a customer process for your object.


--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Sunday, September 22, 2013 at 5:34 AM, Jamie Archibald wrote:

> I'm wondering if camel supports custom object renders (similar to log4j)
> when doing the simple expression language? Currently it appears it just
> calls toString() on the object
>  
> for example.
>  
> .log("Hello World ${body}");
>  
>  
> Rather than calling ${body}.toString() I would like to have it call some
> external bean that knows how to render the object.
>  
> For example
>  
> MyCustomRenderer implement ICamelObjectRenderer {
>  
> public String render(MyObject obj)
> {
> return obj.getName() + obj.getPhoneNumber();
> }
> }
>  
>  
>  
> --  
> Jamie