You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by csanders <cs...@hoovers.com> on 2008/05/13 21:27:15 UTC
First post, ExtendedProperties question
Hi!
Sorry if this has been discussed already, I could not find a 'search'
button on the list archives.
We have a project that uses Velocity, which uses ExtendedProperties,
which we want to extend to interpolate environmental variables and
system properties.
Does anyone have any objection / suggestion for this ? Is we write the
patch is this something that could be included ?
Thanks!
Charlei
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Emmanuel Bourg <eb...@apache.org>.
Henri Yandell a écrit :
> One thing to look for is whether Commons Configuration contains a
> version of ExtendedProperties with this feature. If I understand
> things correctly, the Collections class doesn't seek to be too
> creative because Configuration is adding these types of features.
>
> It might be that the better solution is to modify Velocity to use
> Commons Configuration.
>
> Hen
Commons Configuration is quite heavy weight compared to the simple
ExtendedProperties, that may explain why Velocity didn't replace it.
I'll contact the Velocity team to see if they might be interested in a
patch to support Commons Configuration.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Henri Yandell <fl...@gmail.com>.
One thing to look for is whether Commons Configuration contains a
version of ExtendedProperties with this feature. If I understand
things correctly, the Collections class doesn't seek to be too
creative because Configuration is adding these types of features.
It might be that the better solution is to modify Velocity to use
Commons Configuration.
Hen
On Tue, May 13, 2008 at 12:27 PM, csanders <cs...@hoovers.com> wrote:
> Hi!
>
> Sorry if this has been discussed already, I could not find a 'search'
> button on the list archives.
>
> We have a project that uses Velocity, which uses ExtendedProperties, which
> we want to extend to interpolate environmental variables and system
> properties.
>
> Does anyone have any objection / suggestion for this ? Is we write the
> patch is this something that could be included ?
>
> Thanks!
> Charlei
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Rahul Akolkar <ra...@gmail.com>.
On 5/13/08, csanders <cs...@hoovers.com> wrote:
> Sorry no, I'm looking to patch ExtendedProperties in the collections
> project, is this the right list ?
>
<snip/>
Yes, this is a shared list for all of Commons, please prefix email
subject with [$component] ( in this case, [collections] ).
Though I'd start with the user list.
-Rahul
> Thanks,
> Charlei
>
> Rahul Akolkar wrote:
>
> >
> > If you are looking for Apache Velocity lists, please take a look at this
> page:
> >
> > http://velocity.apache.org/contact.html
> >
> > You probably want the user list.
> >
> > One example of searchable archives (there are others too):
> >
> > http://velocity.markmail.org/
> >
> > -Rahul
> >
> >
> > On 5/13/08, csanders <cs...@hoovers.com> wrote:
> >
> >
> > > Hi!
> > >
> > > Sorry if this has been discussed already, I could not find a 'search'
> > > button on the list archives.
> > >
> > > We have a project that uses Velocity, which uses ExtendedProperties,
> which
> > > we want to extend to interpolate environmental variables and system
> > > properties.
> > >
> > > Does anyone have any objection / suggestion for this ? Is we write the
> > > patch is this something that could be included ?
> > >
> > > Thanks!
> > > Charlei
> > >
> > >
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by csanders <cs...@hoovers.com>.
Sorry no, I'm looking to patch ExtendedProperties in the collections
project, is this the right list ?
Thanks,
Charlei
Rahul Akolkar wrote:
> If you are looking for Apache Velocity lists, please take a look at this page:
>
> http://velocity.apache.org/contact.html
>
> You probably want the user list.
>
> One example of searchable archives (there are others too):
>
> http://velocity.markmail.org/
>
> -Rahul
>
>
> On 5/13/08, csanders <cs...@hoovers.com> wrote:
>
>> Hi!
>>
>> Sorry if this has been discussed already, I could not find a 'search'
>> button on the list archives.
>>
>> We have a project that uses Velocity, which uses ExtendedProperties, which
>> we want to extend to interpolate environmental variables and system
>> properties.
>>
>> Does anyone have any objection / suggestion for this ? Is we write the
>> patch is this something that could be included ?
>>
>> Thanks!
>> Charlei
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Rahul Akolkar <ra...@gmail.com>.
If you are looking for Apache Velocity lists, please take a look at this page:
http://velocity.apache.org/contact.html
You probably want the user list.
One example of searchable archives (there are others too):
http://velocity.markmail.org/
-Rahul
On 5/13/08, csanders <cs...@hoovers.com> wrote:
> Hi!
>
> Sorry if this has been discussed already, I could not find a 'search'
> button on the list archives.
>
> We have a project that uses Velocity, which uses ExtendedProperties, which
> we want to extend to interpolate environmental variables and system
> properties.
>
> Does anyone have any objection / suggestion for this ? Is we write the
> patch is this something that could be included ?
>
> Thanks!
> Charlei
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Emmanuel Bourg <eb...@apache.org>.
csanders a écrit :
> Ahh, and Velocity uses getProperty() .
I'm not sure about this, I looked quickly into the Velocity code, it
seems it mostly uses getString() on the ExtendedProperties, so the
interpolation should work.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by csanders <cs...@hoovers.com>.
Ahh, and Velocity uses getProperty() .
Thanks for all your help on this Emmanuel, and your posts to the
Velocity mailing list :). You're a gentleman and a scholar!
Charlie
Emmanuel Bourg wrote:
> csanders a écrit :
>> Yep, here is the code:
>>
>> CompositeConfiguration config = new CompositeConfiguration();
>> config.addConfiguration(new SystemConfiguration());
>> config.addConfiguration(new EnvironmentConfiguration());
>> config.addConfiguration(new
>> PropertiesConfiguration(Config.velocity_properties_file));
>>
>> System.out.println(config.getProperty("file.resource.loader.path") );
>> System.out.println(config.getProperty("TEMPLATE_HOME") );
>>
>> ExtendedProperties configuration =
>> ConfigurationConverter.getExtendedProperties(config);
>>
>> TEMPLATE_HOME is the env var, and the getProperty() does expand it,
>> but the file.resource.loader.path just returns ${TEMPLATE_HOME} .
>
> config.getProperty() doesn't perform the interpolation, it returns the
> raw property. You have to use config.getString() to retrieve the
> interpolated value.
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Emmanuel Bourg <eb...@apache.org>.
csanders a écrit :
> Yep, here is the code:
>
> CompositeConfiguration config = new CompositeConfiguration();
> config.addConfiguration(new SystemConfiguration());
> config.addConfiguration(new EnvironmentConfiguration());
> config.addConfiguration(new
> PropertiesConfiguration(Config.velocity_properties_file));
>
> System.out.println(config.getProperty("file.resource.loader.path") );
> System.out.println(config.getProperty("TEMPLATE_HOME") );
>
> ExtendedProperties configuration =
> ConfigurationConverter.getExtendedProperties(config);
>
> TEMPLATE_HOME is the env var, and the getProperty() does expand it, but
> the file.resource.loader.path just returns ${TEMPLATE_HOME} .
config.getProperty() doesn't perform the interpolation, it returns the
raw property. You have to use config.getString() to retrieve the
interpolated value.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by csanders <cs...@hoovers.com>.
Yep, here is the code:
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new EnvironmentConfiguration());
config.addConfiguration(new
PropertiesConfiguration(Config.velocity_properties_file));
System.out.println(config.getProperty("file.resource.loader.path") );
System.out.println(config.getProperty("TEMPLATE_HOME") );
ExtendedProperties configuration =
ConfigurationConverter.getExtendedProperties(config);
TEMPLATE_HOME is the env var, and the getProperty() does expand it, but
the file.resource.loader.path just returns ${TEMPLATE_HOME} .
Thanks,
Charlie
Emmanuel Bourg wrote:
> csanders a écrit :
>> I'm having a little trouble getting the interpolation to work, I have
>> a properties file with contents similar to:
>>
>> ---
>> file.resource.loader.path = ${VELOCITY_TEMPLATE_HOME}
>> ---
>>
>> Where VELOCITY_TEMPLATE_HOME is an environmental variable that I need
>> to get expanded , how would I do this ?
>
>
> Did you try the composite configuration example I gave in my previous
> message ?
>
> Emmanuel Bourg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Emmanuel Bourg <eb...@apache.org>.
csanders a écrit :
> I'm having a little trouble getting the interpolation to work, I have a
> properties file with contents similar to:
>
> ---
> file.resource.loader.path = ${VELOCITY_TEMPLATE_HOME}
> ---
>
> Where VELOCITY_TEMPLATE_HOME is an environmental variable that I need to
> get expanded , how would I do this ?
Did you try the composite configuration example I gave in my previous
message ?
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by csanders <cs...@hoovers.com>.
I'm having a little trouble getting the interpolation to work, I have a
properties file with contents similar to:
---
file.resource.loader.path = ${VELOCITY_TEMPLATE_HOME}
---
Where VELOCITY_TEMPLATE_HOME is an environmental variable that I need to
get expanded , how would I do this ?
Thanks,
Charlie
Emmanuel Bourg wrote:
> csanders a écrit :
>
>> We have a project that uses Velocity, which uses ExtendedProperties,
>> which we want to extend to interpolate environmental variables and
>> system properties.
>>
>> Does anyone have any objection / suggestion for this ? Is we write
>> the patch is this something that could be included ?
>
> An alternative is to build a Configuration with Commons Configuration
> that performs the interpolation you want, and then turn it into an
> ExtendedProperties.
>
> The code would look like this:
>
> CompositeConfiguration config = new CompositeConfiguration();
> config.addConfiguration(new SystemConfiguration());
> config.addConfiguration(new EnvironmentConfiguration());
> config.addConfiguration(new PropertiesConfiguration("conf.properties"));
>
> ExtendedProperties props =
> ConfigurationConverter.getExtendedProperties(config);
>
>
> Emmanuel Bourg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: First post, ExtendedProperties question
Posted by Emmanuel Bourg <eb...@apache.org>.
csanders a écrit :
> We have a project that uses Velocity, which uses ExtendedProperties,
> which we want to extend to interpolate environmental variables and
> system properties.
>
> Does anyone have any objection / suggestion for this ? Is we write the
> patch is this something that could be included ?
An alternative is to build a Configuration with Commons Configuration
that performs the interpolation you want, and then turn it into an
ExtendedProperties.
The code would look like this:
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new EnvironmentConfiguration());
config.addConfiguration(new PropertiesConfiguration("conf.properties"));
ExtendedProperties props =
ConfigurationConverter.getExtendedProperties(config);
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org