You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by slush <de...@gmail.com> on 2015/03/11 02:28:46 UTC

Pulling property placeholders out of camel route definitions

Hello. Is it possible to pull out property placeholder names out of route
definitions in Java/XML DSL? For example:

<routes xmlns="http://camel.apache.org/schema/spring">
   <route>
      <from uri="timer://foo?fixedRate=true&amp;delay=0&amp;period=5000" />
      <transform><simple>{{message}}</simple></transform>
      <to uri="log:foo?level=INFO"/>
   </route>
</routes>

Following this:
http://camel.apache.org/loading-routes-from-xml-files.html

I'd want to pull out "message" as a property to-be-supplied programmatically
so I can, for example, dynamically generate an input form based on those
property names and present this to the user to fill in. In my situation I
end up having N instances of this route instantiated. I'd prefer the
properties come from the template for DRY principles.

I looked at the PropertiesComponent as well as its PropertiesParser and
PropertiesResolver but from what I see this doesn't look possible.

Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/Pulling-property-placeholders-out-of-camel-route-definitions-tp5763960.html
Sent from the Camel Development mailing list archive at Nabble.com.

RE: Pulling property placeholders out of camel route definitions

Posted by shreyas <sh...@hotmail.com>.
Not sure if I totally get the requirement. 

But, generally as for as I have used, the work flow is:
1. Decide on all the things that can be configured by users
2. Externalize them into properties
3. Use those properties in your routes
4. Can access them in resolve method as you are aware of these special properties
5. Can be changed externally

You can also use custom PropertiesFuction to may be get these values from database that are changed by User from some UI.

Or is your user inputting the route itself from UI with any possible properties? If this is the case I recommend to restrict what users can input/use as properties or validate that they add those into some DB and your custom function can read from there. 

-Shreyas

----------------------------------------
> Date: Wed, 11 Mar 2015 11:23:02 -0700
> From: derek.abdine@gmail.com
> To: dev@camel.apache.org
> Subject: RE: Pulling property placeholders out of camel route definitions
>
> Hey Shreyas, thanks for the reply.
>
> In this case, I want to pull out all variables from a compiled
> RouteDefinition, be it that route was provided by the Java DSL or XML DSL.
>
> CamelContext#resolvePropertyPlaceholders(String) to my knowledge, works by
> passing in a string template with variables in it, such as:
>
> context.resolvePropertyPlaceholders("{{foo}}");
>
> In this case, consider the string passed in to resolvePropertyPlaceholders
> out of my control. I want to take an aribtrary string that *may* have
> property placeholders in it, pull out those properties and ask the user / a
> system component for them to set them on the camel context so that I may
> then call resolvePropertyPlaceholders on that string with those properties
> fulfilled.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pulling-property-placeholders-out-of-camel-route-definitions-tp5763960p5764017.html
> Sent from the Camel Development mailing list archive at Nabble.com.
 		 	   		  

RE: Pulling property placeholders out of camel route definitions

Posted by slush <de...@gmail.com>.
Hey Shreyas, thanks for the reply.

In this case, I want to pull out all variables from a compiled
RouteDefinition, be it that route was provided by the Java DSL or XML DSL.

CamelContext#resolvePropertyPlaceholders(String) to my knowledge, works by
passing in a string template with variables in it, such as:

context.resolvePropertyPlaceholders("{{foo}}");

In this case, consider the string passed in to resolvePropertyPlaceholders
out of my control. I want to take an aribtrary string that *may* have
property placeholders in it, pull out those properties and ask the user / a
system component for them to set them on the camel context so that I may
then call resolvePropertyPlaceholders on that string with those properties
fulfilled.




--
View this message in context: http://camel.465427.n5.nabble.com/Pulling-property-placeholders-out-of-camel-route-definitions-tp5763960p5764017.html
Sent from the Camel Development mailing list archive at Nabble.com.

RE: Pulling property placeholders out of camel route definitions

Posted by shreyas <sh...@hotmail.com>.
You should be able to use context.resolvePropertyPlaceholders to get this in java DSL



-Shreyas


----------------------------------------
> Date: Tue, 10 Mar 2015 18:28:46 -0700
> From: derek.abdine@gmail.com
> To: dev@camel.apache.org
> Subject: Pulling property placeholders out of camel route definitions
>
> Hello. Is it possible to pull out property placeholder names out of route
> definitions in Java/XML DSL? For example:
>
> <routes xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="timer://foo?fixedRate=true&amp;delay=0&amp;period=5000" />
> <transform><simple>{{message}}</simple></transform>
> <to uri="log:foo?level=INFO"/>
> </route>
> </routes>
>
> Following this:
> http://camel.apache.org/loading-routes-from-xml-files.html
>
> I'd want to pull out "message" as a property to-be-supplied programmatically
> so I can, for example, dynamically generate an input form based on those
> property names and present this to the user to fill in. In my situation I
> end up having N instances of this route instantiated. I'd prefer the
> properties come from the template for DRY principles.
>
> I looked at the PropertiesComponent as well as its PropertiesParser and
> PropertiesResolver but from what I see this doesn't look possible.
>
> Thanks!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Pulling-property-placeholders-out-of-camel-route-definitions-tp5763960.html
> Sent from the Camel Development mailing list archive at Nabble.com.