You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Antonio Petrelli <an...@gmail.com> on 2010/11/29 15:46:53 UTC

[Engine 2.0] Moving to Commons Configuration?

Hi all
I noticed that, in Velocity Engine, the dependency on Commons
Collections is due to the use of ExtendedProperties and LRUMap.

I know what to do with LRUMap (shade the needed classes of Commons
Collections), however I think ExtendedProperties could be replaced
with Commons Configuration. So, if we want, we can move from simple
properties files to other types (e.g. XML, servlet parameters) with no
extra effort. Moreover Commons Configuration allows loading multiple
sources: this is important to me since I would like to implement,
later, the ability to load configuration from multiple files (for
example to load user directives from various JARs automatically,
without configuration).

WDYT?

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Nathan Bubna <nb...@gmail.com>.
I did just notice that the core is dependent on
commons-collections/lang/logging.  Not as excited about that, but
probably still ok, i guess.

http://commons.apache.org/configuration/dependencies.html

On Mon, Nov 29, 2010 at 10:20 AM, Nathan Bubna <nb...@gmail.com> wrote:
> I haven't looked at commons configuration in years.  I'm randomly
> perusing it now.  I like what i see.  It does seem a bit heavy, but i
> suppose it provides a lot more config options than we currently do.
> Considering Engine's position as a library/component project, that's a
> plus.  Let people configure as they need.  I also like their support
> for configuration events; interesting possibilities there.
>
> On Mon, Nov 29, 2010 at 6:46 AM, Antonio Petrelli
> <an...@gmail.com> wrote:
>> Hi all
>> I noticed that, in Velocity Engine, the dependency on Commons
>> Collections is due to the use of ExtendedProperties and LRUMap.
>>
>> I know what to do with LRUMap (shade the needed classes of Commons
>> Collections), however I think ExtendedProperties could be replaced
>> with Commons Configuration. So, if we want, we can move from simple
>> properties files to other types (e.g. XML, servlet parameters) with no
>> extra effort. Moreover Commons Configuration allows loading multiple
>> sources: this is important to me since I would like to implement,
>> later, the ability to load configuration from multiple files (for
>> example to load user directives from various JARs automatically,
>> without configuration).
>>
>> WDYT?
>>
>> Antonio
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: dev-help@velocity.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/30 Adrian Tarau <ad...@gmail.com>:
> Except developers I do not expect anybody to create any implementation.
> However, even in this case "it is not nice" to break other applications if
> not really really necessary.

All this noise, and now I notice you are absolutely right, you only
did not mention the real reasons: other modules that access the
Velocity configuration.
The configuration (in the form of ExtendedProperties) is accessed at
least through VelocityEngine.getProperty, that goes to
RuntimeInstance.getProperty, that loads the property from
ExtendedProperties.
Since we don't know what other modules want as configuration, we must
keep this as generic as possible.

Thanks Adrian, you are right after all :-D

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/30 Adrian Tarau <ad...@gmail.com>:
> Anyway, Velocity should not depend on 2 external libraries just to be able
> to setup the configuration. The core should not depend on anything else
> except J2SE.

Sure. In fact I plan to have a simple implementation what uses a
Properties instance.
After that, it could be possible to plug an implementation that uses
commons configuration.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Adrian Tarau <ad...@gmail.com>.
Except developers I do not expect anybody to create any implementation. 
However, even in this case "it is not nice" to break other applications 
if not really really necessary.

I personally would not mind to have the configuration as java object, it 
would be probably less confusion for the average developer. Question 
like "what keys to use to do X and Y" would probably dissapear(maybe :) 
) since the configuration will be pure Java objects(with comments).

Anyway, Velocity should not depend on 2 external libraries just to be 
able to setup the configuration. The core should not depend on anything 
else except J2SE.

On 11/30/2010 09:51 AM, Antonio Petrelli wrote:
> 2010/11/30 Adrian Tarau<ad...@gmail.com>:
>    
>> Since it is an interface adding getUserDirectives2 will break my
>> application. That's the downside with interfaces, if you add stuff things
>> will not compile anymore and everybody is forced to adjust their code - not
>> a big deal in this case, but ...
>>      
> Wait a moment, with the exception of Velocity developers, is anyone
> intentioned on creating configuration implementations?
> If not, I think it's not a problem.
> If yes, you will notice that, after upgrading, you will have a
> compilation failure, and it's a *good* thing, since it lets you know
> something new happened.
> Anyway, a "support" (implementation of an interface with all methods
> doing nothing) protects against this kind of compilation problems.
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/30 Adrian Tarau <ad...@gmail.com>:
> Since it is an interface adding getUserDirectives2 will break my
> application. That's the downside with interfaces, if you add stuff things
> will not compile anymore and everybody is forced to adjust their code - not
> a big deal in this case, but ...

Wait a moment, with the exception of Velocity developers, is anyone
intentioned on creating configuration implementations?
If not, I think it's not a problem.
If yes, you will notice that, after upgrading, you will have a
compilation failure, and it's a *good* thing, since it lets you know
something new happened.
Anyway, a "support" (implementation of an interface with all methods
doing nothing) protects against this kind of compilation problems.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Adrian Tarau <ad...@gmail.com>.
Since it is an interface adding getUserDirectives2 will break my 
application. That's the downside with interfaces, if you add stuff 
things will not compile anymore and everybody is forced to adjust their 
code - not a big deal in this case, but ...

Sticking to getInt(key), getString(key), getList(key), getDouble(key) 
will be better I would say.

On 11/30/2010 03:48 AM, Antonio Petrelli wrote:
> 2010/11/29 Adrian Tarau<ad...@gmail.com>:
>    
>> If you would start doing specific gets/sets then you might want to do the
>> whole configuration like that otherwise it will become a hard mix of generic
>> gets and specific gets. And since it is an interface adding new specific
>> gets/sets will break the compatibility very easy.
>>      
> No, I meant *only* specific gets.
> But I don't think it breaks compatibility. The configuration interface
> can evolve in two ways: add or remove methods.
> About removing, with minor releases the methods cannot be removed,
> only deprecated.
> About adding, it is not a problem of previously-released versions of
> Velocity, since the new "properties" will be ignored.
>
>    
>> Sticking with loose get/sets it would be probably better. I'm using Jakarta
>> Configuration and injecting a Jakarta Configuration "sub-configuration"
>> wrapped on a Velocity configuration will work well for me :)
>>      
> It works, but I disagree when you say "it works well", as in "it's
> easy to understand by a programmer POV".
> What I have in mind is something similar to Spring pure Java
> configuration, without the annotations. Yes, XML works, but the pure
> Java configuration works better :-D
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/29 Adrian Tarau <ad...@gmail.com>:
> If you would start doing specific gets/sets then you might want to do the
> whole configuration like that otherwise it will become a hard mix of generic
> gets and specific gets. And since it is an interface adding new specific
> gets/sets will break the compatibility very easy.

No, I meant *only* specific gets.
But I don't think it breaks compatibility. The configuration interface
can evolve in two ways: add or remove methods.
About removing, with minor releases the methods cannot be removed,
only deprecated.
About adding, it is not a problem of previously-released versions of
Velocity, since the new "properties" will be ignored.

> Sticking with loose get/sets it would be probably better. I'm using Jakarta
> Configuration and injecting a Jakarta Configuration "sub-configuration"
> wrapped on a Velocity configuration will work well for me :)

It works, but I disagree when you say "it works well", as in "it's
easy to understand by a programmer POV".
What I have in mind is something similar to Spring pure Java
configuration, without the annotations. Yes, XML works, but the pure
Java configuration works better :-D

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Adrian Tarau <ad...@gmail.com>.
If you would start doing specific gets/sets then you might want to do 
the whole configuration like that otherwise it will become a hard mix of 
generic gets and specific gets. And since it is an interface adding new 
specific gets/sets will break the compatibility very easy.

Sticking with loose get/sets it would be probably better. I'm using 
Jakarta Configuration and injecting a Jakarta Configuration 
"sub-configuration" wrapped on a Velocity configuration will work well 
for me :)

On 11/29/2010 02:34 PM, Nathan Bubna wrote:
> On Mon, Nov 29, 2010 at 11:24 AM, Antonio Petrelli
> <an...@gmail.com>  wrote:
>    
>> 2010/11/29 Adrian Tarau<ad...@gmail.com>:
>>      
>>> What I wanted to say is to follow the model and not to include any
>>> dependency.
>>>        
>> Ok
>>
>>      
>>> A minimal functionality should be to set/get primitive types and
>>> work with lists and store everything behind as strings(with "," as separator
>>> for lists).
>>>        
>> Not entirely true, only "gets" are needed, since configuration is read-only.
>>      
> at least it is at the present...
>
>    
>>> I do not thing there is a need for anything else then storing
>>> bools(is feature A enabled/disabled), ints, strings and list of strings for
>>> Velocity.
>>>        
>> Sure, but having developer-friendly methods, like "getUserDirectives"
>> and such, easies the development.
>> Anyway let me work on it, if you don't like it we can still revert it ;-)
>>
>> Antonio
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: dev-help@velocity.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Nov 29, 2010 at 11:36 AM, Antonio Petrelli
<an...@gmail.com> wrote:
> 2010/11/29 Nathan Bubna <nb...@gmail.com>:
>> On Mon, Nov 29, 2010 at 11:24 AM, Antonio Petrelli
>> <an...@gmail.com> wrote:
>>> 2010/11/29 Adrian Tarau <ad...@gmail.com>:
>>>> What I wanted to say is to follow the model and not to include any
>>>> dependency.
>>>
>>> Ok
>>>
>>>> A minimal functionality should be to set/get primitive types and
>>>> work with lists and store everything behind as strings(with "," as separator
>>>> for lists).
>>>
>>> Not entirely true, only "gets" are needed, since configuration is read-only.
>>
>> at least it is at the present...
>
> Sure, but at that point we can use some well-established patterns,
> like a "MutableThingy", with setters/adders, and then use a specific
> implementation to serialize it.

:) just so long as we aren't ruling it out at the start.


>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/29 Nathan Bubna <nb...@gmail.com>:
> On Mon, Nov 29, 2010 at 11:24 AM, Antonio Petrelli
> <an...@gmail.com> wrote:
>> 2010/11/29 Adrian Tarau <ad...@gmail.com>:
>>> What I wanted to say is to follow the model and not to include any
>>> dependency.
>>
>> Ok
>>
>>> A minimal functionality should be to set/get primitive types and
>>> work with lists and store everything behind as strings(with "," as separator
>>> for lists).
>>
>> Not entirely true, only "gets" are needed, since configuration is read-only.
>
> at least it is at the present...

Sure, but at that point we can use some well-established patterns,
like a "MutableThingy", with setters/adders, and then use a specific
implementation to serialize it.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Nov 29, 2010 at 11:24 AM, Antonio Petrelli
<an...@gmail.com> wrote:
> 2010/11/29 Adrian Tarau <ad...@gmail.com>:
>> What I wanted to say is to follow the model and not to include any
>> dependency.
>
> Ok
>
>> A minimal functionality should be to set/get primitive types and
>> work with lists and store everything behind as strings(with "," as separator
>> for lists).
>
> Not entirely true, only "gets" are needed, since configuration is read-only.

at least it is at the present...

>> I do not thing there is a need for anything else then storing
>> bools(is feature A enabled/disabled), ints, strings and list of strings for
>> Velocity.
>
> Sure, but having developer-friendly methods, like "getUserDirectives"
> and such, easies the development.
> Anyway let me work on it, if you don't like it we can still revert it ;-)
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/29 Adrian Tarau <ad...@gmail.com>:
> What I wanted to say is to follow the model and not to include any
> dependency.

Ok

> A minimal functionality should be to set/get primitive types and
> work with lists and store everything behind as strings(with "," as separator
> for lists).

Not entirely true, only "gets" are needed, since configuration is read-only.

> I do not thing there is a need for anything else then storing
> bools(is feature A enabled/disabled), ints, strings and list of strings for
> Velocity.

Sure, but having developer-friendly methods, like "getUserDirectives"
and such, easies the development.
Anyway let me work on it, if you don't like it we can still revert it ;-)

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Adrian Tarau <ad...@gmail.com>.
Antonie,

What I wanted to say is to follow the model and not to include any 
dependency. A minimal functionality should be to set/get primitive types 
and work with lists and store everything behind as strings(with "," as 
separator for lists). I do not thing there is a need for anything else 
then storing bools(is feature A enabled/disabled), ints, strings and 
list of strings for Velocity.

On 11/29/2010 02:05 PM, Antonio Petrelli wrote:
> 2010/11/29 Adrian Tarau<ad...@gmail.com>:
>    
>> I would really like to see the configuration as an interface and provide
>> factories to create a configuration based on a simple Map or Jakarta Commons
>> Configuration(or something else).
>>
>> This would allow any developer to inject their own configuration into
>> Velocity without the need to pass around values.
>>      
> Good idea! The real configuration implementation will go to a
> different module then.
>
>    
>> org.apache.commons.configuration.Configuration could be used as a model and
>> eventually some things could be dropped(like sub-configurations?)
>>      
> I think it's better to have a Velocity-specific configuration as an
> interface and an implementation that uses Commons Configuration.
> This can be a later step though. Adding an interface will remove the
> dependency on ExtendedProperties, that will go into a new module.
>
>    
>> Thanks.
>>      
> Thanks to you
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/11/29 Adrian Tarau <ad...@gmail.com>:
> I would really like to see the configuration as an interface and provide
> factories to create a configuration based on a simple Map or Jakarta Commons
> Configuration(or something else).
>
> This would allow any developer to inject their own configuration into
> Velocity without the need to pass around values.

Good idea! The real configuration implementation will go to a
different module then.

> org.apache.commons.configuration.Configuration could be used as a model and
> eventually some things could be dropped(like sub-configurations?)

I think it's better to have a Velocity-specific configuration as an
interface and an implementation that uses Commons Configuration.
This can be a later step though. Adding an interface will remove the
dependency on ExtendedProperties, that will go into a new module.

> Thanks.

Thanks to you

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Adrian Tarau <ad...@gmail.com>.
I would really like to see the configuration as an interface and provide 
factories to create a configuration based on a simple Map or Jakarta 
Commons Configuration(or something else).

This would allow any developer to inject their own configuration into 
Velocity without the need to pass around values. 
org.apache.commons.configuration.Configuration could be used as a model 
and eventually some things could be dropped(like sub-configurations?)

Thanks.

On 11/29/2010 01:20 PM, Nathan Bubna wrote:
> I haven't looked at commons configuration in years.  I'm randomly
> perusing it now.  I like what i see.  It does seem a bit heavy, but i
> suppose it provides a lot more config options than we currently do.
> Considering Engine's position as a library/component project, that's a
> plus.  Let people configure as they need.  I also like their support
> for configuration events; interesting possibilities there.
>
> On Mon, Nov 29, 2010 at 6:46 AM, Antonio Petrelli
> <an...@gmail.com>  wrote:
>    
>> Hi all
>> I noticed that, in Velocity Engine, the dependency on Commons
>> Collections is due to the use of ExtendedProperties and LRUMap.
>>
>> I know what to do with LRUMap (shade the needed classes of Commons
>> Collections), however I think ExtendedProperties could be replaced
>> with Commons Configuration. So, if we want, we can move from simple
>> properties files to other types (e.g. XML, servlet parameters) with no
>> extra effort. Moreover Commons Configuration allows loading multiple
>> sources: this is important to me since I would like to implement,
>> later, the ability to load configuration from multiple files (for
>> example to load user directives from various JARs automatically,
>> without configuration).
>>
>> WDYT?
>>
>> Antonio
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: dev-help@velocity.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Re: [Engine 2.0] Moving to Commons Configuration?

Posted by Nathan Bubna <nb...@gmail.com>.
I haven't looked at commons configuration in years.  I'm randomly
perusing it now.  I like what i see.  It does seem a bit heavy, but i
suppose it provides a lot more config options than we currently do.
Considering Engine's position as a library/component project, that's a
plus.  Let people configure as they need.  I also like their support
for configuration events; interesting possibilities there.

On Mon, Nov 29, 2010 at 6:46 AM, Antonio Petrelli
<an...@gmail.com> wrote:
> Hi all
> I noticed that, in Velocity Engine, the dependency on Commons
> Collections is due to the use of ExtendedProperties and LRUMap.
>
> I know what to do with LRUMap (shade the needed classes of Commons
> Collections), however I think ExtendedProperties could be replaced
> with Commons Configuration. So, if we want, we can move from simple
> properties files to other types (e.g. XML, servlet parameters) with no
> extra effort. Moreover Commons Configuration allows loading multiple
> sources: this is important to me since I would like to implement,
> later, the ability to load configuration from multiple files (for
> example to load user directives from various JARs automatically,
> without configuration).
>
> WDYT?
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org