Yeah, LIKE I SAID, I know I can break out to a bean or a processor, but
that is such a heavyweight solution to do something so simple that really
should be built into Camel. You have to create a class, come up with some
meaningful name of the class, repeat that name a couple of times if using a
Spring DSL, etc.

Let's say we do it with anonymous classes in a Java DSL:

  process(new Processor()
  {
        @Override
         public void process(Exchange exchange) throws Exception
         {
               exchange.getIn().getBody(MyBodyType.class)

.setSomeProperty(exchange.getIn().getHeader("foo", SomeType.class);
         }
  })

Or perhaps better as a bean:

  bean( new Object()
  {
      public void set( @Body MyBodyType body, @Header("foo") value)
      {
          body.setSomeProperty(value);
      }
  }

I personally would rather replace any of those with something more like
this in DSL:

  body().set("someProperty", header("foo"))

This is much more obvious what is happening when looking at the route.



On Tue, Sep 3, 2013 at 1:51 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Tue, Sep 3, 2013 at 5:51 PM, Dale King <dalewk...@gmail.com> wrote:
> > Through simple and OGNL we have nice easy ways to read the properties of
> > beans in the body, headers, or properties. But what I cannot find is an
> > easy way to invoke a setter on a bean property, but perhaps I am missing
> > something.
> >
> > I can certainly create a bean or processor to invoke the setter, but it
> > seems to me that if I am forced to do it for something as simple as
> setting
> > a property then something is missing in Camel. I try to do as much as
> > possible in Camel.
> >
> > I can certainly use another language like javascript, groovy, or el to do
> > it, but once again bringing in a whole new language seems like overkill
> > just to set a property.
> >
> > So 3 operations that i don't see an easy way to do in Camel without
> > resorting to these heavyweight solutions are:
> >
> >  - Set a bean property
> >  - More generally, you should be able to invoke any method on a bean
> > including with parameters
> >  - Create a new instance of a bean (possibly with parameters)
> >
> > Correct me if I am wrong and there is a simple way to do these.
> >
>
> Well there is something called Java programming language, where you
> can do all that ;)
>
> > --
> > Dale King
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Dale King

Reply via email to