You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Atle Prange (JIRA)" <ji...@apache.org> on 2009/01/05 15:57:06 UTC

[jira] Created: (CAMEL-1226) String formatter / interpolator for dsl uris

String formatter / interpolator for dsl uris
--------------------------------------------

                 Key: CAMEL-1226
                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
             Project: Apache Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Atle Prange
            Priority: Minor


Often one ends up with dsl expressions that build strings like:
{code}
 from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
{code}

Would in not be better to write
{code}
from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
{code}
, where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)

To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48499#action_48499 ] 

James Strachan commented on CAMEL-1226:
---------------------------------------

I'm thinking that we'd add something like this

{code}
public Builder toFormat(String format, Object... args) {
  return to(String.format(format, args));
}
{code}

Then use the same encoding conventions as the [String.format() method|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)]

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-1226:
-------------------------------

    Fix Version/s: 2.0.0

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-1226.
--------------------------------

    Resolution: Fixed

New Revision: 753155

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Atle Prange (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48491#action_48491 ] 

Atle Prange commented on CAMEL-1226:
------------------------------------

i guess the ugly way would be to define a new method that takes the 
string and vararg list that interpolates the string with the arguments. 
Suggestions for method names: uri(String templates, Objec ... values), 
interpolate(...), buildUri(...))

{code}
from("direct:start").to( intepolate( "ldps:localhost:{1}?base={2}", port, query) );
{code}






> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Atle Prange (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Atle Prange closed CAMEL-1226.
------------------------------


Good work!

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Atle Prange (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48525#action_48525 ] 

Atle Prange commented on CAMEL-1226:
------------------------------------

I agree with you.

Maybe buildUri() would be appropriate?





> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Atle Prange (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48503#action_48503 ] 

Atle Prange commented on CAMEL-1226:
------------------------------------

That seems to do the trick, with the plus that it is already part of the 
JDK, and one could use some String.format static import elsewhere and 
still keep the same conventions.
If i could choose i would pick the method name "format()" instead of 
"toFormat()", it seems more elegant to me....





> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48485#action_48485 ] 

Claus Ibsen commented on CAMEL-1226:
------------------------------------

I think the builder for *to* already have varargs for a pipeline with N destinations. 
{code}
from("direct:start").to("log:foo", "bean:validate", "bean:process", "mail:xxxx")
{code}

So it can't really be done without adding some rules such as if the first parameter is a string and it has {1} placeholders then these remaining parameters are for these placeholders.
Or something like that. 

Any ideas?

But the idea is very cool and something I would like to have as well. Making the route much easier to read as well. I kinda miss Groovy and it's $ support for Strings. Damm Java starts to feel "old"



> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-1226:
----------------------------------

    Assignee: Claus Ibsen

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48526#action_48526 ] 

Claus Ibsen commented on CAMEL-1226:
------------------------------------

+1 to buildUri

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=50496#action_50496 ] 

Claus Ibsen commented on CAMEL-1226:
------------------------------------

I decided for a short notation - *toF* and *fromF*

{code}
                from("direct:start").toF("file://%s?fileName=%s", path, name);

                fromF("file://%s?include=%s", path, pattern).toF("mock:%s", result);
{code}

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48495#action_48495 ] 

James Strachan commented on CAMEL-1226:
---------------------------------------

The spring property place holders works already AFAIK as you say

{code}
<endpoint id="foo" uri="ldps:localhost:${port}?base=${query}"/>
{code}




> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48499#action_48499 ] 

jstrachan edited comment on CAMEL-1226 at 1/6/09 4:18 AM:
---------------------------------------------------------------

I'm thinking that we'd add something like this

{code}
public Builder toFormat(String format, Object... args) {
  return to(String.format(format, args));
}
{code}

Then use the same encoding conventions as the [String.format() method|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)] using the [JDK standard format syntax|http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax]

      was (Author: jstrachan):
    I'm thinking that we'd add something like this

{code}
public Builder toFormat(String format, Object... args) {
  return to(String.format(format, args));
}
{code}

Then use the same encoding conventions as the [String.format() method|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)]
  
> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48504#action_48504 ] 

James Strachan commented on CAMEL-1226:
---------------------------------------

the issue with 'format' is it reads like you are formatting the message - rather than formatting the URI string used to send a message to somewhere. So I think something like toFormat() or toUriFormat() is cleaner

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48492#action_48492 ] 

Claus Ibsen commented on CAMEL-1226:
------------------------------------

I anticipate you are thinking of using java.text.MessageFormat since the placeholders is what it's using.

Not a bad idea with the builder method. I dont think many end users is familiar with the intepolate term, so I kinda like:
- toUri
- buildUri
- formatUri
Or what is a good name.

For Spring DSL end users should use <endpoint id="foo" uri="xxx"/> where you can use spring property placeholders
And then use ref for this endpoint. <to ref="foo"/>

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48486#action_48486 ] 

Claus Ibsen commented on CAMEL-1226:
------------------------------------

And besides we might wanna thing if we can do something for this as well in the Spring DSL

> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48497#action_48497 ] 

James Strachan commented on CAMEL-1226:
---------------------------------------

If we do add a helper method - we should probably name it in line with the use of the static import.

so

{code}
from("direct:start").
  to( format( "ldps:localhost:{1}?base={2}", port, query) );
{code}

or

{code}
from("direct:start").
  toFormat( "ldps:localhost:{1}?base={2}", port, query);
{code}





> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "Atle Prange (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48498#action_48498 ] 

Atle Prange commented on CAMEL-1226:
------------------------------------

I have seen so many different ways of representing the placeholder, but 
why not use a java API standard.

Other examples are EL: #{0}, #{1}; StringFormat: %s, %s...






> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1226) String formatter / interpolator for dsl uris

Posted by "James Strachan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48496#action_48496 ] 

James Strachan commented on CAMEL-1226:
---------------------------------------

BTW String.format() is part of the JDK now. So with a static import code would look like this...

{code}
from("direct:start").to( format( "ldps:localhost:{1}?base={2}", port, query) );
{code}

The great thing about this approach is you can use the format() method for any parameter that takes a string. It also works with varargs.

{code}
from("direct:start").
  to( format( "ldps:localhost:{1}?base={2}", port, query).
       format("jms:{1}", somequeue) );
{code}



> String formatter / interpolator for dsl uris
> --------------------------------------------
>
>                 Key: CAMEL-1226
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1226
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Atle Prange
>            Priority: Minor
>
> Often one ends up with dsl expressions that build strings like:
> {code}
>  from("direct:start").to("ldap:localhost:" + port + "?base=" + query);
> {code}
> Would in not be better to write
> {code}
> from("direct:start").to("ldps:localhost:{1}?base={2}", port, query);
> {code}
> , where "{1}" means "the first argument in the string varargs following. ( "{1}" could of course be replaced by some expression that you like the format of)
> To implementent this one could overload the from() and to() methods to accept a vararg array of Strings following the uri argument, and interpolate the uri with the varargs...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.