You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jinaLu <ji...@yahoo.com> on 2013/03/18 12:35:58 UTC

dynamic properties

I need to have configurable text with some parameters to set in the body.
In my .cfg file I have
message=My message ${property.type} is for user ${property.user}
Properties are set in steps before.
If I use setBody(simple("{{message}}") I get text without properties
parameters. Any ideas how to set body with needed parameters?

Other similar problem is when I need to get property by dynamic name
Something like setHeader("My",
simple("{{userName."+"${property.name}"+"}}")). Something like that, but I
do get an error if I try to execute this, as property.name doesn't produce
property value... Any ideas?

Thank you a lot



--
View this message in context: http://camel.465427.n5.nabble.com/dynamic-properties-tp5729339.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: dynamic properties

Posted by Christian Müller <ch...@gmail.com>.
I think you are looking for a template engine like [1], [2] or [3].

[1] http://camel.apache.org/freemarker.html
[2] http://camel.apache.org/velocity.html
[3] http://camel.apache.org/stringtemplate.html

Best,
Christian

On Tue, Mar 19, 2013 at 7:29 AM, jinaLu <ji...@yahoo.com> wrote:

> I use camel 2.8 according my serviceMix server.
> In cfg I have:
> message=My message ${property.type} is for user ${property.user}
> messageSubject.invoice=Invoice message
>
> I use Java DSL to define route and osgi blueprint for other purposes. My
> route looks like:
> from("direct:start")
> .to("bean:FindXML")
> .setProperty("type", xpath("/message/@Type"))
> .setProperty("user", xpath("/message/@To"))
> .to("bean:SomeActions")
>  .setHeader("messageText", simple("{{message}}"))
>  .setHeader("messageSubject",
> simple("{{messageSubject.${property.type}}}"))
>
> None of this header setters work.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/dynamic-properties-tp5729339p5729395.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Re: dynamic properties

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 19, 2013 at 7:29 AM, jinaLu <ji...@yahoo.com> wrote:
> I use camel 2.8 according my serviceMix server.
> In cfg I have:
> message=My message ${property.type} is for user ${property.user}
> messageSubject.invoice=Invoice message
>

You need a newer release of Camel like 2.9 onwards to do this.
For example if you use Apache ServiceMix 4.5.x, that comes with Camel 2.10.x


> I use Java DSL to define route and osgi blueprint for other purposes. My
> route looks like:
> from("direct:start")
> .to("bean:FindXML")
> .setProperty("type", xpath("/message/@Type"))
> .setProperty("user", xpath("/message/@To"))
> .to("bean:SomeActions")
>  .setHeader("messageText", simple("{{message}}"))
>  .setHeader("messageSubject", simple("{{messageSubject.${property.type}}}"))
>
> None of this header setters work.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/dynamic-properties-tp5729339p5729395.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

Re: dynamic properties

Posted by jinaLu <ji...@yahoo.com>.
I use camel 2.8 according my serviceMix server.
In cfg I have:
message=My message ${property.type} is for user ${property.user} 
messageSubject.invoice=Invoice message

I use Java DSL to define route and osgi blueprint for other purposes. My
route looks like:
from("direct:start")
.to("bean:FindXML")
.setProperty("type", xpath("/message/@Type"))
.setProperty("user", xpath("/message/@To"))
.to("bean:SomeActions")
 .setHeader("messageText", simple("{{message}}"))
 .setHeader("messageSubject", simple("{{messageSubject.${property.type}}}"))

None of this header setters work.



--
View this message in context: http://camel.465427.n5.nabble.com/dynamic-properties-tp5729339p5729395.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: dynamic properties

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

See this page how to use property placeholders with Camel
http://camel.apache.org/using-propertyplaceholder.html

What version of Camel do you use?
And do you use Spring or OSGi blueprint, or something?

And what is  ${property.type}
is that another property placeholder with a key=type,eg

eg from a .cfg or .properties file you have:

type=Some bla goes here
user=Some other bla here
message=My message ${property.type} is for user ${property.user}




On Mon, Mar 18, 2013 at 12:35 PM, jinaLu <ji...@yahoo.com> wrote:
> I need to have configurable text with some parameters to set in the body.
> In my .cfg file I have
> message=My message ${property.type} is for user ${property.user}
> Properties are set in steps before.
> If I use setBody(simple("{{message}}") I get text without properties
> parameters. Any ideas how to set body with needed parameters?
>
> Other similar problem is when I need to get property by dynamic name
> Something like setHeader("My",
> simple("{{userName."+"${property.name}"+"}}")). Something like that, but I
> do get an error if I try to execute this, as property.name doesn't produce
> property value... Any ideas?
>
> Thank you a lot
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/dynamic-properties-tp5729339.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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