Re: [Configuration]VFSFileSystem

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]VFSFileSystem

rzorzorzo
Ralph,

I have now had the time to build the configuration project from
trunk/head and to test your changes.
It now works as expected.
I am currently not able to test the proxy settings. I will get back to
you with these test results later.

Thanks for your efforts and for this great framework.

BTW: have you ever considered supporting templating within a configuration.
This would allow something like this (using velocity)

locale.specific.porperty = #if
($System.getProperty("locale").startsWith("en")) #then en_texts #else
default_texts

which could help define a single configuration file for multiple platforms.

- Ron

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]VFSFileSystem

Ralph Goers

On Aug 18, 2009, at 12:58 AM, rzo wrote:

> Ralph,
>
> I have now had the time to build the configuration project from  
> trunk/head and to test your changes.
> It now works as expected.
> I am currently not able to test the proxy settings. I will get back  
> to you with these test results later.
>
> Thanks for your efforts and for this great framework.
>
> BTW: have you ever considered supporting templating within a  
> configuration.
> This would allow something like this (using velocity)
>
> locale.specific.porperty = #if  
> ($System.getProperty("locale").startsWith("en")) #then en_texts  
> #else default_texts
>
> which could help define a single configuration file for multiple  
> platforms.
>

a. Commons Configuration already supports variables. You can register  
your own lookup that can implement that functionality.
b. I added an expression lookup that uses JEXL. I've tested it with  
DefaultConfigurationBuilder but it should work in any configuration.  
If you run mvn site you will find the documentation for this.

Ralph

Reply | Threaded
Open this post in threaded view
|

[Configuration]JEXL question

rzorzorzo
Hello,

thanks for mentioning jexl scripting.
I tried it out and have found the following issue:

evaluating the following:

test=${expr:if (System.getProperty("user.home").startsWith("C")) {"x";}
else {"z";}}

does not seem to work.
Debuging shows that the expression forwarded to jexl is:

if (System.getProperty("user.home").startsWith("C")) {"x";

is this a bug ? or is there a way to escape the brackets within ${...} ?

- Ron



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]JEXL question

Ralph Goers

On Aug 29, 2009, at 6:33 AM, rzo wrote:

> Hello,
>
> thanks for mentioning jexl scripting.
> I tried it out and have found the following issue:
>
> evaluating the following:
>
> test=${expr:if (System.getProperty("user.home").startsWith("C"))  
> {"x";} else {"z";}}
>
> does not seem to work.
> Debuging shows that the expression forwarded to jexl is:
>
> if (System.getProperty("user.home").startsWith("C")) {"x";
>
> is this a bug ? or is there a way to escape the brackets within $
> {...} ?
>

The "bug" is actually the way  
org.apache.commons.lang.text.StrSubstitutor works. It can configured  
be with prefix and suffix characters - the defaults are '{' and '}'  
and after finding the prefix it just searches for the first occurance  
of the suffix character - unless it finds a recursive variable. So the  
string passed to ConfigurationInterpolator is what you show above.

However, it might be possible to override the suffix matcher to look  
for an escape character.

Ralph


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]JEXL question

Ralph Goers

On Aug 29, 2009, at 10:35 AM, Ralph Goers wrote:

>
> On Aug 29, 2009, at 6:33 AM, rzo wrote:
>
>> Hello,
>>
>> thanks for mentioning jexl scripting.
>> I tried it out and have found the following issue:
>>
>> evaluating the following:
>>
>> test=${expr:if (System.getProperty("user.home").startsWith("C"))  
>> {"x";} else {"z";}}
>>
>> does not seem to work.
>> Debuging shows that the expression forwarded to jexl is:
>>
>> if (System.getProperty("user.home").startsWith("C")) {"x";
>>
>> is this a bug ? or is there a way to escape the brackets within $
>> {...} ?
>>
>
> The "bug" is actually the way  
> org.apache.commons.lang.text.StrSubstitutor works. It can configured  
> be with prefix and suffix characters - the defaults are '{' and '}'  
> and after finding the prefix it just searches for the first  
> occurance of the suffix character - unless it finds a recursive  
> variable. So the string passed to ConfigurationInterpolator is what  
> you show above.
>
> However, it might be possible to override the suffix matcher to look  
> for an escape character.
>

It occurs to me though that just using a different suffix matcher will  
not remove the escape character.

One other thought. StrSubstitutor allows the prefix and suffix  
characters to be replaced, so you should be able to do

conf.getSubstitutor().setVariablePrefix('`');
conf.getSubstitutor().setVariablesuffix('`');

and then use test="$`expr:if (System.getProperty
("user.home").startsWith("C")) {"x";} else {"z";}`

It also supports using strings so you could do:

conf.getSubstitutor.setVariableSuffix("$}";

and then test="${expr:if (System.getProperty("user.home").startsWith
("C")) {"x";} else {"z";}$}

Of course, then you would have to use those prefix and suffix  
characters throughout that configuration.

Ralph


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]JEXL question

rzorzorzo
Ralph,

thanks for the fast reply.
In the mean time i decided to try it with groovy.
I have written a groovy expression interpolation which I will be using
in my project.
If you are interested in this i could put the files on jira.

- Ron


Ralph Goers wrote:

>
> On Aug 29, 2009, at 10:35 AM, Ralph Goers wrote:
>
>>
>> On Aug 29, 2009, at 6:33 AM, rzo wrote:
>>
>>> Hello,
>>>
>>> thanks for mentioning jexl scripting.
>>> I tried it out and have found the following issue:
>>>
>>> evaluating the following:
>>>
>>> test=${expr:if (System.getProperty("user.home").startsWith("C"))
>>> {"x";} else {"z";}}
>>>
>>> does not seem to work.
>>> Debuging shows that the expression forwarded to jexl is:
>>>
>>> if (System.getProperty("user.home").startsWith("C")) {"x";
>>>
>>> is this a bug ? or is there a way to escape the brackets within
>>> ${...} ?
>>>
>>
>> The "bug" is actually the way
>> org.apache.commons.lang.text.StrSubstitutor works. It can configured
>> be with prefix and suffix characters - the defaults are '{' and '}'
>> and after finding the prefix it just searches for the first occurance
>> of the suffix character - unless it finds a recursive variable. So
>> the string passed to ConfigurationInterpolator is what you show above.
>>
>> However, it might be possible to override the suffix matcher to look
>> for an escape character.
>>
>
> It occurs to me though that just using a different suffix matcher will
> not remove the escape character.
>
> One other thought. StrSubstitutor allows the prefix and suffix
> characters to be replaced, so you should be able to do
>
> conf.getSubstitutor().setVariablePrefix('`');
> conf.getSubstitutor().setVariablesuffix('`');
>
> and then use test="$`expr:if
> (System.getProperty("user.home").startsWith("C")) {"x";} else {"z";}`
>
> It also supports using strings so you could do:
>
> conf.getSubstitutor.setVariableSuffix("$}";
>
> and then test="${expr:if
> (System.getProperty("user.home").startsWith("C")) {"x";} else {"z";}$}
>
> Of course, then you would have to use those prefix and suffix
> characters throughout that configuration.
>
> Ralph
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Configuration]JEXL question

Ralph Goers
Sure, by all means.

Ralph

On Aug 29, 2009, at 11:28 AM, rzo wrote:

> Ralph,
>
> thanks for the fast reply.
> In the mean time i decided to try it with groovy.
> I have written a groovy expression interpolation which I will be  
> using in my project.
> If you are interested in this i could put the files on jira.
>
> - Ron
>
>
> Ralph Goers wrote:
>>
>> On Aug 29, 2009, at 10:35 AM, Ralph Goers wrote:
>>
>>>
>>> On Aug 29, 2009, at 6:33 AM, rzo wrote:
>>>
>>>> Hello,
>>>>
>>>> thanks for mentioning jexl scripting.
>>>> I tried it out and have found the following issue:
>>>>
>>>> evaluating the following:
>>>>
>>>> test=${expr:if (System.getProperty("user.home").startsWith("C"))  
>>>> {"x";} else {"z";}}
>>>>
>>>> does not seem to work.
>>>> Debuging shows that the expression forwarded to jexl is:
>>>>
>>>> if (System.getProperty("user.home").startsWith("C")) {"x";
>>>>
>>>> is this a bug ? or is there a way to escape the brackets within $
>>>> {...} ?
>>>>
>>>
>>> The "bug" is actually the way  
>>> org.apache.commons.lang.text.StrSubstitutor works. It can  
>>> configured be with prefix and suffix characters - the defaults are  
>>> '{' and '}' and after finding the prefix it just searches for the  
>>> first occurance of the suffix character - unless it finds a  
>>> recursive variable. So the string passed to  
>>> ConfigurationInterpolator is what you show above.
>>>
>>> However, it might be possible to override the suffix matcher to  
>>> look for an escape character.
>>>
>>
>> It occurs to me though that just using a different suffix matcher  
>> will not remove the escape character.
>>
>> One other thought. StrSubstitutor allows the prefix and suffix  
>> characters to be replaced, so you should be able to do
>>
>> conf.getSubstitutor().setVariablePrefix('`');
>> conf.getSubstitutor().setVariablesuffix('`');
>>
>> and then use test="$`expr:if (System.getProperty
>> ("user.home").startsWith("C")) {"x";} else {"z";}`
>>
>> It also supports using strings so you could do:
>>
>> conf.getSubstitutor.setVariableSuffix("$}";
>>
>> and then test="${expr:if (System.getProperty("user.home").startsWith
>> ("C")) {"x";} else {"z";}$}
>>
>> Of course, then you would have to use those prefix and suffix  
>> characters throughout that configuration.
>>
>> Ralph
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]