You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephane Bailliez <sb...@apache.org> on 2004/02/25 10:36:10 UTC
[configuration] comma delimited properties
Following a private email with Eric.
There is an underlying problem in configuration regarding the handling of
comma delimited properties.
As of now, a comma delimited string is considered a list of values, so
something like:
java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
will return a list made of { 'ldap://server:390/ou=something' , 'o=else',
'c=here' } when doing a getProperty() and a getString() will return the
first element on the list.
Hardly a convenience to initialize an ldap/jndi connection.
I made a couple of suggestions (some were very stupids actually like a
contract with the toString method on the object) , and Eric suggested a
decorator or a subclass.
I'm not sure that the decorator/subclass would be appropriate as it would
probably mean yet another decoration/subclass which might interfere with the
fact that we may want this behavior in just every configuration class. Let's
face it, we may want to handle list and non list in the same configuration
subset
I think that the best thing to do is to enforce that the getString() method
should return whatever property as its original value.
Thoughts ?
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Stephane Bailliez wrote:
> Yes. Thought about that too, but I was wondering if it was really judicious
> to start adding such kind of methods here.
>
> Plus it does not really solve the problem at all because we can have various
> properties in the same subset that may need to be handled differently and
> I'm not sure it is the way to go to do isSplitString()/setSplitString() in
> retrieving properties. Think about this:
>
> ldap.java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
> ldap.someproperty=this,is,a,real,list,of,values
>
> Stephane
You could work around this issue with :
ldap.java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
ldap.someproperty=this
ldap.someproperty=is
ldap.someproperty=a
ldap.someproperty=real
ldap.someproperty=list
ldap.someproperty=of
ldap.someproperty=values
I prefer this syntax to the coma separated values.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Stephane Bailliez <sb...@apache.org>.
"Emmanuel Bourg" <eb...@micropole-univers.com> wrote in message
news:200402261039.LAA13217@vertigo-back.micropole.com...
> getObject() would not really simplify the syntax, i don't think it's
> worth adding this method as it turns
Think of it as a factory method and a method extraction from getObjectList()
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
Stephane Bailliez wrote:
>>imho the multiple lines syntax is cleaner and easier to handle.
>
> I'm ok for this as it is close to what you would do with an xml element.
> Though...
There may be an issue with DatabaseConfiguration and JNDIConfiguration
though. This should be solvable for the DatabaseConfiguration, but i'm
not sure for the JNDIConfiguration.
> What do you think about a getObjectList(Class primitive, char delim) and
> getObject(Class primitive) ?
getObject() would not really simplify the syntax, i don't think it's
worth adding this method as it turns
MyType type = new MyType(configuration.getString(key));
into
MyType type = (MyType) configuration.getObject(MyType.class, key);
getObjectList() is more interesting.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Stephane Bailliez <sb...@apache.org>.
"Emmanuel Bourg" <eb...@micropole-univers.com> wrote in message
news:200402251351.OAA20511@vertigo-back.micropole.com...
[...]
> imho the multiple lines syntax is cleaner and easier to handle.
I'm ok for this as it is close to what you would do with an xml element.
Though...
What do you think about a getObjectList(Class primitive, char delim) and
getObject(Class primitive) ?
It could be useful as it allows to specify any class that implements a
constructor with a string parameter.
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
I wonder if we shouldn't even deprecate or remove the use of multiple
properties on a single line. Currently we only support arrays for
strings, but sooner or later I think we will add arrays for all the
types supported (getIntArray, getByteArray, etc), and if we keep the
property splitting, we will have to find a separator that works with all
types simultaneously.
"," : conflicts with the grouping separator of a decimal format if we
add a Configuration.getNumberFormat() method in the future.
":" : conflicts with URLs syntax if we add a Configuration.getURL() method.
";" : conflict with the DecimalFormat syntax. It may also be used in URLs.
"|" : maybe a good candidate for a default separator, until we want to
add a basic type using it.
imho the multiple lines syntax is cleaner and easier to handle.
Emmanuel Bourg
Eric Pugh wrote:
> To be honest.. I think at some point we may be forced to do this in
> PropertiesConfiguration.(post 1.0!):
>
> 1) If you want to do this: ldap.someproperty=this,is,a,real,list,of,values
> then you do this:
> ldap.someproperty=this
> ldap.someproperty=is
> ldap.someproperty=a
> ldap.someproperty=real
> ldap.someproperty=list
> ldap.someproperty=of
> ldap.someproperty=values
>
> 2) setPropertyDelimator(";")
> ldap.java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
> ldap.someproperty=this;is;a;real;list;of;values
>
>
> In fact, maybe option 2 isn't so bad? I mean, eventually you are going to
> have to make a decision, are ","'s a delimiter or not.. And why should it
> only be "," characters? Would someone like to send in a patch and unit test
> for setStringSplitting and setListDelimiter?
>
> Eric
>
>
>
>
>
>
>>-----Original Message-----
>>From: news [mailto:news@sea.gmane.org]On Behalf Of Stephane Bailliez
>>Sent: Wednesday, February 25, 2004 1:32 PM
>>To: commons-dev@jakarta.apache.org
>>Subject: Re: [configuration] comma delimited properties
>>
>>
>>"Emmanuel Bourg" <eb...@micropole-univers.com> wrote in message
>>news:200402251024.LAA29028@vertigo-back.micropole.com...
>>
>>>I agree, i noticed this issue last month and suggested a patch :
>>>
>>>
>>
>>http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg
>>33704.html
>>
>>>Basically it adds a setSplitString(boolean) method in the
>>>AbstractConfiguration class that enable or disable property
>>
>>splitting.
>>
>>Yes. Thought about that too, but I was wondering if it was
>>really judicious
>>to start adding such kind of methods here.
>>
>>Plus it does not really solve the problem at all because we
>>can have various
>>properties in the same subset that may need to be handled
>>differently and
>>I'm not sure it is the way to go to do
>>isSplitString()/setSplitString() in
>>retrieving properties. Think about this:
>>
>>ldap.java.naming.provider.url=ldap://server:390/ou=something,o
>>=else,c=here
>>ldap.someproperty=this,is,a,real,list,of,values
>>
>>Stephane
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [configuration] comma delimited properties
Posted by Eric Pugh <ep...@upstate.com>.
To be honest.. I think at some point we may be forced to do this in
PropertiesConfiguration.(post 1.0!):
1) If you want to do this: ldap.someproperty=this,is,a,real,list,of,values
then you do this:
ldap.someproperty=this
ldap.someproperty=is
ldap.someproperty=a
ldap.someproperty=real
ldap.someproperty=list
ldap.someproperty=of
ldap.someproperty=values
2) setPropertyDelimator(";")
ldap.java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
ldap.someproperty=this;is;a;real;list;of;values
In fact, maybe option 2 isn't so bad? I mean, eventually you are going to
have to make a decision, are ","'s a delimiter or not.. And why should it
only be "," characters? Would someone like to send in a patch and unit test
for setStringSplitting and setListDelimiter?
Eric
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Stephane Bailliez
> Sent: Wednesday, February 25, 2004 1:32 PM
> To: commons-dev@jakarta.apache.org
> Subject: Re: [configuration] comma delimited properties
>
>
> "Emmanuel Bourg" <eb...@micropole-univers.com> wrote in message
> news:200402251024.LAA29028@vertigo-back.micropole.com...
> > I agree, i noticed this issue last month and suggested a patch :
> >
> >
> http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg
> 33704.html
> >
> > Basically it adds a setSplitString(boolean) method in the
> > AbstractConfiguration class that enable or disable property
> splitting.
>
> Yes. Thought about that too, but I was wondering if it was
> really judicious
> to start adding such kind of methods here.
>
> Plus it does not really solve the problem at all because we
> can have various
> properties in the same subset that may need to be handled
> differently and
> I'm not sure it is the way to go to do
> isSplitString()/setSplitString() in
> retrieving properties. Think about this:
>
> ldap.java.naming.provider.url=ldap://server:390/ou=something,o
> =else,c=here
> ldap.someproperty=this,is,a,real,list,of,values
>
> Stephane
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Stephane Bailliez <sb...@apache.org>.
"Emmanuel Bourg" <eb...@micropole-univers.com> wrote in message
news:200402251024.LAA29028@vertigo-back.micropole.com...
> I agree, i noticed this issue last month and suggested a patch :
>
> http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg33704.html
>
> Basically it adds a setSplitString(boolean) method in the
> AbstractConfiguration class that enable or disable property splitting.
Yes. Thought about that too, but I was wondering if it was really judicious
to start adding such kind of methods here.
Plus it does not really solve the problem at all because we can have various
properties in the same subset that may need to be handled differently and
I'm not sure it is the way to go to do isSplitString()/setSplitString() in
retrieving properties. Think about this:
ldap.java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
ldap.someproperty=this,is,a,real,list,of,values
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [configuration] comma delimited properties
Posted by Eric Pugh <ep...@upstate.com>.
Is that going to be generic enough... I guess one of my concerns is that as
we have more providers, like DatabaseConfiguration, that the changes we make
stay generic...
I guess, in this case, that the DatabaseConfiguration returns a string, and
then that gets converted to a list/array by AbstractConfiguration. So, by
applying your setSplitString() method, that would solve the problem.
However, I guess we need to document that the ConfigurationFactory doesn't
support setting this method. So, is the consensus that setSplitString() is
the way to go? Your patch didn't seem to handle the getting, only the
setting, correct?
Part of why we want everything to inherit from AbstractConfiguration is to
help enforce similar behavior across all providers.
Eric
> -----Original Message-----
> From: Emmanuel Bourg [mailto:ebourg@micropole-univers.com]
> Sent: Wednesday, February 25, 2004 11:27 AM
> To: Jakarta Commons Developers List
> Subject: Re: [configuration] comma delimited properties
>
>
> I agree, i noticed this issue last month and suggested a patch :
>
> http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg
> 33704.html
>
> Basically it adds a setSplitString(boolean) method in the
> AbstractConfiguration class that enable or disable property splitting.
>
> Emmanuel Bourg
>
>
> Stephane Bailliez wrote:
>
> > Following a private email with Eric.
> >
> > There is an underlying problem in configuration regarding
> the handling of
> > comma delimited properties.
> > As of now, a comma delimited string is considered a list of
> values, so
> > something like:
> >
> >
> java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
> >
> > will return a list made of {
> 'ldap://server:390/ou=something' , 'o=else',
> > 'c=here' } when doing a getProperty() and a getString()
> will return the
> > first element on the list.
> >
> > Hardly a convenience to initialize an ldap/jndi connection.
> >
> > I made a couple of suggestions (some were very stupids
> actually like a
> > contract with the toString method on the object) , and Eric
> suggested a
> > decorator or a subclass.
> >
> > I'm not sure that the decorator/subclass would be
> appropriate as it would
> > probably mean yet another decoration/subclass which might
> interfere with the
> > fact that we may want this behavior in just every
> configuration class. Let's
> > face it, we may want to handle list and non list in the
> same configuration
> > subset
> >
> > I think that the best thing to do is to enforce that the
> getString() method
> > should return whatever property as its original value.
> >
> > Thoughts ?
> >
> > Stephane
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] comma delimited properties
Posted by Emmanuel Bourg <eb...@micropole-univers.com>.
I agree, i noticed this issue last month and suggested a patch :
http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg33704.html
Basically it adds a setSplitString(boolean) method in the
AbstractConfiguration class that enable or disable property splitting.
Emmanuel Bourg
Stephane Bailliez wrote:
> Following a private email with Eric.
>
> There is an underlying problem in configuration regarding the handling of
> comma delimited properties.
> As of now, a comma delimited string is considered a list of values, so
> something like:
>
> java.naming.provider.url=ldap://server:390/ou=something,o=else,c=here
>
> will return a list made of { 'ldap://server:390/ou=something' , 'o=else',
> 'c=here' } when doing a getProperty() and a getString() will return the
> first element on the list.
>
> Hardly a convenience to initialize an ldap/jndi connection.
>
> I made a couple of suggestions (some were very stupids actually like a
> contract with the toString method on the object) , and Eric suggested a
> decorator or a subclass.
>
> I'm not sure that the decorator/subclass would be appropriate as it would
> probably mean yet another decoration/subclass which might interfere with the
> fact that we may want this behavior in just every configuration class. Let's
> face it, we may want to handle list and non list in the same configuration
> subset
>
> I think that the best thing to do is to enforce that the getString() method
> should return whatever property as its original value.
>
> Thoughts ?
>
> Stephane
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org