Re: [CVE-2020-1953] Uncontrolled class instantiation when loading YAML files in Apache Commons Configuration

2020-03-13 Thread Oliver Heger
The form at Mitre was just submitted, so I assume that the issue will be
visible soon.

Oliver

Am 12.03.20 um 19:18 schrieb Gary Gregory:
> Note that  https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-1953 is not
> "live" yet.
> 
> Gary
> 
> On Thu, Mar 12, 2020 at 1:53 PM Oliver Heger  wrote:
> 
>> CVE-2020-1953: Uncontrolled class instantiation when loading YAML files
>> in Apache Commons Configuration
>>
>> Severity: Moderate
>>
>> Vendor:
>> The Apache Software Foundation
>>
>> Versions Affected:
>> 2.2 to 2.6
>>
>> Description:
>> Apache Commons Configuration uses a third-party library to parse YAML
>> files which by default allows the instantiation of classes if the YAML
>> includes special statements. If a YAML file is from an untrusted source,
>> it can therefore load and execute code out of the control of the host
>> application.
>>
>> Mitigation:
>> Users should upgrade to to 2.7, which prevents class instantiation by
>> the YAML processor.
>>
>> Credit:
>> This issue was discovered by Daniel Kalinowski of ISEC.pl Research Team
>>
>> Oliver Heger
>> on behalf of the Apache Commons PMC
>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[CVE-2020-1953] Uncontrolled class instantiation when loading YAML files in Apache Commons Configuration

2020-03-12 Thread Oliver Heger
CVE-2020-1953: Uncontrolled class instantiation when loading YAML files
in Apache Commons Configuration

Severity: Moderate

Vendor:
The Apache Software Foundation

Versions Affected:
2.2 to 2.6

Description:
Apache Commons Configuration uses a third-party library to parse YAML
files which by default allows the instantiation of classes if the YAML
includes special statements. If a YAML file is from an untrusted source,
it can therefore load and execute code out of the control of the host
application.

Mitigation:
Users should upgrade to to 2.7, which prevents class instantiation by
the YAML processor.

Credit:
This issue was discovered by Daniel Kalinowski of ISEC.pl Research Team

Oliver Heger
on behalf of the Apache Commons PMC


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons-configurations2 doesn't strip double quotes in env variable

2019-08-28 Thread Oliver Heger
>From looking in the code, the problem seems to be in the
DefaultConversionHandler class, which is eventually invoked to convert a
value into an array or a collection. In the protected extractValues()
method a DisabledListDelimiterHandler is used to process the value -
which of course does not handle the delimiter character. To be honest, I
don't know why it was implemented that way; this could be considered a bug.

A work-around could be to implement a custom ConversionHandler that
extends DefaultConversionHandler. Here you can override the
extractValues() method, and if the value is a String, you can delegate
to the split() method of a DefaultListDelimiterHandler.

Oliver

Am 28.08.19 um 13:11 schrieb Duc Tran:
> Thank you Oliver,
> 
> I am aware of the ListDelimiterHandler. And in the code I already
> declare that[1] when loading properties files and having a test to prove
> the ListDelimiterHandler is working. but the issue with ENV variables
> still remains[2]. Then I had to do a tricky hack to resolve the problem
> but doesn't satisfy so I reached to the mailing list.
> 
> Do you have any idea?
> 
> [1]
> https://github.com/linagora/james-project/blob/10f7aaf9a440b1bc83e88e1842b4b89fff5c96ec/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java#L80
> 
> [2]
> https://github.com/linagora/james-project/pull/2622/commits/538be74ef1a9e713db0a68b13ac2e35fc68f1df3
> 
> 
> 
> 
> 
>> Hello Duc,
>>
>> the problem you are facing is probably not related to double quotes, but
>> to a change in the way delimiter characters in strings are handled.
>>
>> In configuration 2.x the splitting of strings at delimiter characters is
>> disabled per default. But you can enable this feature by setting a
>> suitable ListDelimiterHandler. This is described in the user's guide [1].
>>
>> HTH
>> Oliver
>> [1]
>> http://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#List_handling
>>
>>
>>> Am 23.08.19 um 05:04 schrieb Duc Tran:
>>> Hello, I'm Duc, and in our projects, we just upgraded from
>>> commons-configuration 1.9 to 2.5 and we found that when passing env
>>> variables into properties file as a list like
>>> `key=${env:MY_LIST_VARIABLES}` where MY_LIST_VARIABLES is "value1,
>>> value2, value3", the new commons configuration 2.5 doesn't strip double
>>> quotes. This makes `properites.getStringArray("key")` returns an array
>>> with only element is the big string ["value1, value2, value3"] instead
>>> of what I expected and what the commons-configuration 1 does returns
>>> ["value1", "value2", "value3"]
>>>
>>> So, do you have any suggestion to keep that behavior with
>>> commons-configuration 2.5?
>>>
>>>
>>> Thank you!
>>>
>>> Duc Tran Tien,
> 
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: commons-configurations2 doesn't strip double quotes in env variable

2019-08-27 Thread Oliver Heger
Hello Duc,

the problem you are facing is probably not related to double quotes, but
to a change in the way delimiter characters in strings are handled.

In configuration 2.x the splitting of strings at delimiter characters is
disabled per default. But you can enable this feature by setting a
suitable ListDelimiterHandler. This is described in the user's guide [1].

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#List_handling

Am 23.08.19 um 05:04 schrieb Duc Tran:
> Hello, I'm Duc, and in our projects, we just upgraded from
> commons-configuration 1.9 to 2.5 and we found that when passing env
> variables into properties file as a list like
> `key=${env:MY_LIST_VARIABLES}` where MY_LIST_VARIABLES is "value1,
> value2, value3", the new commons configuration 2.5 doesn't strip double
> quotes. This makes `properites.getStringArray("key")` returns an array
> with only element is the big string ["value1, value2, value3"] instead
> of what I expected and what the commons-configuration 1 does returns
> ["value1", "value2", "value3"]
> 
> So, do you have any suggestion to keep that behavior with
> commons-configuration 2.5?
> 
> 
> Thank you!
> 
> Duc Tran Tien,
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [lang3] Problem with the OSGi metadata: Bundle-SymbolicName / breaking change between 3.7 and 3.8

2018-09-06 Thread Oliver Heger
Hi Phil,

as you already assume, this change in the OSGi meta data was caused by
changes in the build process and not intended.

So opening a ticket in Jira would be the correct action to take.

Thank you for reporting!
Oliver

Am 06.09.2018 um 20:49 schrieb P. Ottlinger:
> Hi,
> 
> I've just stumbled upon a problem that prevents me from updating from
> 3.7 to 3.8 in an OSGi context.
> 
> Although the release has just been a patch one, the bundle's symbolic
> name changed
> from "Bundle-SymbolicName org.apache.commons.lang3" in 3.7.0
> to "Bundle-SymbolicName org.apache.commons.commons-lang3" in 3.8.0.
> 
> That makes it impossible to do a drop-in update, as it is a breaking change.
> 
> Is that change an error in 3.8.0 or a wanted one that could be
> communicated more directly to downstream users?
> 
> May I file a bugticket in the LANG-Jira for it? I assume there has been
> a hickup when building the OSGi release JAR and the change was not intended.
> 
> Thanks,
> Phil
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.3 Released

2018-08-09 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.3.

The Apache Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

Version 2.3 is another maintenance release for the Configuration 2.x
series. It contains bug fixes and also a few new features like support
for File and Path as data types. The release is fully source and binary
compatible with version 2.2.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

A user's guide describing all the features of Configuration 2.x can be
found at
  http://commons.apache.org/configuration/userguide/user_guide.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

Please verify signatures using the KEYS file available at the above
location when downloading the release.

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Reloading properties does not work as expected

2018-02-06 Thread Oliver Heger
Hi,

the reloading examples have been fixed, and the site was redeployed.
Thanks again.

Oliver

Am 01.02.2018 um 10:26 schrieb Paul Wellner Bou:
> Hi,
> 
> thank you very much.
> 
> Yes, this helps. This is more or less what I found out as well. That's why
> I introduced the 6 seconds delay in my original example, to wait for this
> 5s timeout.
> I tried to call getProperty more than once, too, because I noticed
> debugging that the check time is only filled after the first call.
> 
> But somehow I wrote my test code in a way, that the reloading time was the
> same as the time the file changed (which may happen in unit tests, its the
> same millisecond). So the test failed again.
> 
> Now I reordered the statements a bit, and it works now. I just need to add
> a call in the very beginning of the test. The timeouts I introduced in the
> first approach are already enough.
> 
> So it works now. Thanks very much!
> https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7
> 
>> i am trying to implement a reloadable property using commons-reloading2
>>> (2.2), without success. I tried to follow the (outdated) examples on
>>>
>> https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
>>> (both of them).
>>
>> Could you be a bit more specific about what is outdated, so that we can
>> update the examples?
>>
> 
> Sure:
> https://gist.github.com/paulwellnerbou/3e309535a8a516477dc2bede478f79f2/revisions
> Maybe you could add that commons-beanutils:1.9.3 is required to avoid the
> NoClassDefFoundException (
> https://stackoverflow.com/questions/16266047/very-simple-apache-commons-configuration-example-throws-noclassdeffounderror
> ).
> 
> Cheers,
> Paul.
> 
>>
>>> Now I created a unit test against this API which I would expect it to
>> pass,
>>> but it doesn't:
>>> https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7
>>>
>>> Any idea what I am doing wrong?
>>
>> I had a deeper look at the test and the implementation, and here is what
>> I found out:
>>
>> The class for checking whether a reload of a file is required is
>> FileHandlerReloadingDetector. The class records the time of the last
>> check and has a refreshDelay property; it only checks again after the
>> time configured for the delay is elapsed. The default refreshDelay is 5
>> seconds. This is one reason why your test does not pass; you need to
>> decrease this delay or wait longer.
>>
>> The other reason is that there is indeed a problem in the implementation
>> that causes the first call to getConfiguration() to get missed by the
>> reload checker. The CONFIGURATION_REQUEST event is already fired before
>> the file to be loaded is properly initialized, and therefore, the
>> checker cannot set its last check time. This is initialized only at the
>> second call to getConfiguration(). So the test would only be successful
>> if getConfiguration() was called another time (taking the refresh delay
>> into account).
>>
>> This can be considered a bug, but is probably not very problematic in
>> practice when the configuration is accessed on a regular basis.
>>
>> HTH
>> Oliver
>>
>>
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Reloading properties does not work as expected

2018-01-31 Thread Oliver Heger
Hi,

Am 30.01.2018 um 10:18 schrieb Paul Wellner Bou:
> Good morning,
> 
> i am trying to implement a reloadable property using commons-reloading2
> (2.2), without success. I tried to follow the (outdated) examples on
> https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
> (both of them).

Could you be a bit more specific about what is outdated, so that we can
update the examples?

> 
> Now I created a unit test against this API which I would expect it to pass,
> but it doesn't:
> https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7
> 
> Any idea what I am doing wrong?

I had a deeper look at the test and the implementation, and here is what
I found out:

The class for checking whether a reload of a file is required is
FileHandlerReloadingDetector. The class records the time of the last
check and has a refreshDelay property; it only checks again after the
time configured for the delay is elapsed. The default refreshDelay is 5
seconds. This is one reason why your test does not pass; you need to
decrease this delay or wait longer.

The other reason is that there is indeed a problem in the implementation
that causes the first call to getConfiguration() to get missed by the
reload checker. The CONFIGURATION_REQUEST event is already fired before
the file to be loaded is properly initialized, and therefore, the
checker cannot set its last check time. This is initialized only at the
second call to getConfiguration(). So the test would only be successful
if getConfiguration() was called another time (taking the refresh delay
into account).

This can be considered a bug, but is probably not very problematic in
practice when the configuration is accessed on a regular basis.

HTH
Oliver

> 
> Thank you and kind regards
> Paul.
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Problem Migrating from 1.x to 2.x, my XMLBeanDeclaration is key no Longer Valid

2017-10-28 Thread Oliver Heger
Hello,

Am 27.10.2017 um 22:26 schrieb John Boyer:
> Hello:
> 
> I’m working on migrating my codebase from Commons Configuration 1.x to 2.x. 
> However, in version 2, I receive an error indicating that the key I used in 
> 1.x is invalid:
>  
>   org.apache.commons.configuration2.ex.ConfigurationRuntimeException: 
> Passed in key must select exactly one node (found 0): ios.invitation
> 
> 
> —-
> The string dump of my XMLConfiguration appears as follows:
> 
> ios/invitation/@config-class=com.example.email.DefaultEventEmailFormatter
> ios/invitation/@fileName=request-cancel
> ios/invitation/@subject=Itty-Bitty Skedi | Invitation
> ios/invitation/@name=Invitation
> ios/invitation/@senderFirstName=Itty-Bitty
> ios/invitation/@shortDescription=You have a new notification waiting for you 
> in the Skedi app.
> ios/invitation/@fromEmailAddress=donotre...@example.com
> ios/invitation/@contentType=text/plain
> ios/invitation/@senderLastName=Skedi

>From this dump it looks as if the configuration is using an
XPathExpressionEngine. Note that the slash is used as separator for
property keys.

> 
> 
> —-
> The XML file is:
> 
> 
> 
>   
>   
>  
> config-class=“com.example.email.DefaultEventEmailFormatter”
>   contentType="text/plain"
>   fromEmailAddress=“donotre...@example.com”
>   senderFirstName="Itty-Bitty"
>   senderLastName="Skedi"
>   subject="Itty-Bitty Skedi | Invitation"
>   shortDescription="You have a new notification waiting 
> for you in the Skedi app."
>   name="Invitation"
>   fileName="request-cancel"/>
>   
> 
> 
> —-
> The Java code snippet:
> 
> XMLConfiguration xmlConfig = builder.getConfiguration();
> log.info(ConfigurationUtils.toString(xmlConfig));
> 
> BeanDeclaration decl = new XMLBeanDeclaration(xmlConfig, 
> “ios.invitation”);//where `ios.invitation` is the key

They key you pass to the bean declaration is expressed in terms of the
default expression engine. To be compliant with the configuration, you
should use the key "ios/invitation".

I do not know why the problem occurs after you switch to Configuration
2.x. But the cause seems to be that the key you use is actually wrong
because it cannot be interpreted correctly by the expression engine.

Oliver

> 
> —-
> 
> Can anyone help me to resolve this problem?
> 
> Thank you for your time in advance.
> 
> Regards,
> 
> John Boyer
> 
> 
> 
> 
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.2 Released

2017-10-13 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.2.

The Apache Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

Version 2.2 is another maintenance release for the Configuration 2.x
series. It contains a number of bug fixes and also some new features.
Among the highlights is the new support for JSON and YAML
configurations. The release is fully source and binary compatible with
version 2.1.1.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

A user's guide describing all the features of Configuration 2.x can be
found at
  http://commons.apache.org/configuration/userguide/user_guide.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

Please verify signatures using the KEYS file available at the above
location when downloading the release.

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Release date for commons-configuration2 ?

2017-10-01 Thread Oliver Heger


Am 01.10.2017 um 14:23 schrieb Andreas Kuhtz:
> Hi Oliver,
> Thank you for the published SNAPSHOT build.
> 
> I've provided a JIRA issue and PR for the Java 9 module name:
> https://github.com/apache/commons-configuration/pull/6

Many thanks!

I will have a look (probably in a few days).

Oliver

> 
> Cheers,
> Andreas
> 
> 2017-09-28 21:48 GMT+02:00 Oliver Heger <oliver.he...@oliver-heger.de>:
> 
>>
>>
>> Am 27.09.2017 um 08:33 schrieb Andreas Kuhtz:
>>> Hi Gary,
>>>
>>> I wasn't aware that pushing a SNAPSHOT build needs the release process
>> will
>>> all preparations to be executed, but I'll wait for the next release in
>> this
>>> case.
>>> Thank you for all the good solutions that are provided by the
>> configuration
>>> team.
>>
>> For just uploading a SNAPSHOT, no release preparations should be
>> required. I have just done so, so you should now find a recent version
>> in the SNAPSHOT repository referred to by Pascal.
>>
>> Regarding a release: This is indeed on my todo list, but not with
>> highest priority. I may need some more weeks until I get to it. (If a RM
>> is available earlier, that would be great.)
>>
>> The codebase should be in a state that it can be released. There are no
>> blocking issues in Jira. We should, however, add the Java 9 module name.
>>
>> Oliver
>>
>>>
>>> Andreas
>>>
>>> 2017-09-26 22:17 GMT+02:00 Gary Gregory <garydgreg...@gmail.com>:
>>>
>>>> On Tue, Sep 26, 2017 at 2:07 PM, Andreas Kuhtz <andreas.ku...@gmail.com
>>>
>>>> wrote:
>>>>
>>>>> Thank you for the response.
>>>>> I looked at http://repository.apache.org/snapshots/ already, but there
>>>> is
>>>>> no 2.2-SNAPSHOT. If someone has permissions to publish the current
>>>>> 2.2-SNAPSHOT that would be great.
>>>>>
>>>>
>>>> Unfortunately, it's more complicated than that. We have a release
>> process
>>>> that requires a release manager from our team to volunteer and jump
>> through
>>>> a bunch of hoops.
>>>>
>>>> Gary
>>>>
>>>> <http://repository.apache.org/snapshots/>
>>>>>
>>>>> 2017-09-26 21:59 GMT+02:00 Pascal Schumacher <pascalschumac...@gmx.net
>>> :
>>>>>
>>>>>> Sorry my response was less that clear. The public maven repo address
>>>> is:
>>>>>> http://repository.apache.org/snapshots/
>>>>>>
>>>>>> See: https://www.apache.org/dev/repository-faq.html#basic
>>>>>>
>>>>>>
>>>>>> Am 26.09.2017 um 21:56 schrieb Pascal Schumacher:
>>>>>>
>>>>>>> No idea if there are concrete plans for a release date of
>>>>>>> commons-configuration 2.2 with the YAML feature.
>>>>>>>
>>>>>>> https://repository.apache.org/content/groups/snapshots/org/a
>>>>>>> pache/commons/commons-configuration2/ should have a snapshots with
>>>> the
>>>>>>> feature.
>>>>>>>
>>>>>>> Kind regards,
>>>>>>> Pascal
>>>>>>>
>>>>>>> Am 26.09.2017 um 21:43 schrieb Andreas Kuhtz:
>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> Is there a planned release date for commons-configuration2 or is a
>>>>>>>> SNAPSHOT
>>>>>>>> available in a public maven repo?
>>>>>>>>
>>>>>>>> I would like to use the YAML configuration in my project.
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Andreas
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> 
>> -
>>>>>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>>>>>> For additional commands, e-mail: user-h...@commons.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> -
>>>>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>>>>> For additional commands, e-mail: user-h...@commons.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Release date for commons-configuration2 ?

2017-09-28 Thread Oliver Heger


Am 27.09.2017 um 08:33 schrieb Andreas Kuhtz:
> Hi Gary,
> 
> I wasn't aware that pushing a SNAPSHOT build needs the release process will
> all preparations to be executed, but I'll wait for the next release in this
> case.
> Thank you for all the good solutions that are provided by the configuration
> team.

For just uploading a SNAPSHOT, no release preparations should be
required. I have just done so, so you should now find a recent version
in the SNAPSHOT repository referred to by Pascal.

Regarding a release: This is indeed on my todo list, but not with
highest priority. I may need some more weeks until I get to it. (If a RM
is available earlier, that would be great.)

The codebase should be in a state that it can be released. There are no
blocking issues in Jira. We should, however, add the Java 9 module name.

Oliver

> 
> Andreas
> 
> 2017-09-26 22:17 GMT+02:00 Gary Gregory :
> 
>> On Tue, Sep 26, 2017 at 2:07 PM, Andreas Kuhtz 
>> wrote:
>>
>>> Thank you for the response.
>>> I looked at http://repository.apache.org/snapshots/ already, but there
>> is
>>> no 2.2-SNAPSHOT. If someone has permissions to publish the current
>>> 2.2-SNAPSHOT that would be great.
>>>
>>
>> Unfortunately, it's more complicated than that. We have a release process
>> that requires a release manager from our team to volunteer and jump through
>> a bunch of hoops.
>>
>> Gary
>>
>> 
>>>
>>> 2017-09-26 21:59 GMT+02:00 Pascal Schumacher :
>>>
 Sorry my response was less that clear. The public maven repo address
>> is:
 http://repository.apache.org/snapshots/

 See: https://www.apache.org/dev/repository-faq.html#basic


 Am 26.09.2017 um 21:56 schrieb Pascal Schumacher:

> No idea if there are concrete plans for a release date of
> commons-configuration 2.2 with the YAML feature.
>
> https://repository.apache.org/content/groups/snapshots/org/a
> pache/commons/commons-configuration2/ should have a snapshots with
>> the
> feature.
>
> Kind regards,
> Pascal
>
> Am 26.09.2017 um 21:43 schrieb Andreas Kuhtz:
>
>> Hello,
>>
>> Is there a planned release date for commons-configuration2 or is a
>> SNAPSHOT
>> available in a public maven repo?
>>
>> I would like to use the YAML configuration in my project.
>>
>> Best regards,
>> Andreas
>>
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>

 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org


>>>
>>
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Release date for commons-configuration2 ?

2017-09-27 Thread Oliver Heger


Am 27.09.2017 um 11:08 schrieb mingleizhang:
> It seems I can not directly convert a file to a java Properties class in this 
> package. I hope it like this.
> 
> 
> read(fileName: String): Properties
> 
Wouldn't Properties.load() do the trick?

Oliver

> 
> Rice.
> 
> 
> 
> 
> 
> 
> 
> At 2017-09-27 14:33:01, "Andreas Kuhtz"  wrote:
>> Hi Gary,
>>
>> I wasn't aware that pushing a SNAPSHOT build needs the release process will
>> all preparations to be executed, but I'll wait for the next release in this
>> case.
>> Thank you for all the good solutions that are provided by the configuration
>> team.
>>
>> Andreas
>>
>> 2017-09-26 22:17 GMT+02:00 Gary Gregory :
>>
>>> On Tue, Sep 26, 2017 at 2:07 PM, Andreas Kuhtz 
>>> wrote:
>>>
 Thank you for the response.
 I looked at http://repository.apache.org/snapshots/ already, but there
>>> is
 no 2.2-SNAPSHOT. If someone has permissions to publish the current
 2.2-SNAPSHOT that would be great.

>>>
>>> Unfortunately, it's more complicated than that. We have a release process
>>> that requires a release manager from our team to volunteer and jump through
>>> a bunch of hoops.
>>>
>>> Gary
>>>
>>> 

 2017-09-26 21:59 GMT+02:00 Pascal Schumacher :

> Sorry my response was less that clear. The public maven repo address
>>> is:
> http://repository.apache.org/snapshots/
>
> See: https://www.apache.org/dev/repository-faq.html#basic
>
>
> Am 26.09.2017 um 21:56 schrieb Pascal Schumacher:
>
>> No idea if there are concrete plans for a release date of
>> commons-configuration 2.2 with the YAML feature.
>>
>> https://repository.apache.org/content/groups/snapshots/org/a
>> pache/commons/commons-configuration2/ should have a snapshots with
>>> the
>> feature.
>>
>> Kind regards,
>> Pascal
>>
>> Am 26.09.2017 um 21:43 schrieb Andreas Kuhtz:
>>
>>> Hello,
>>>
>>> Is there a planned release date for commons-configuration2 or is a
>>> SNAPSHOT
>>> available in a public maven repo?
>>>
>>> I would like to use the YAML configuration in my project.
>>>
>>> Best regards,
>>> Andreas
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>

>>>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Creating a properties file

2017-08-31 Thread Oliver Heger


Am 31.08.2017 um 08:12 schrieb Thomas Mortagne:
> OK but my use case is that the file may or may not already exist and
> if it already exist I need to modify it, not overwrite it.

I see. Then there is a constructor of FileBasedConfigurationBuilder that
accepts a boolean allowFailOnInit flag. Setting this flag to true will
cause the behavior you are probably after: If the file does not exist,
an empty configuration is created. Otherwise, it is loaded from the file.

Oliver

> 
> My point is that I did not really needed to care about that in 1.x.
> 
> On Wed, Aug 30, 2017 at 5:49 PM, Oliver Heger
> <oliver.he...@oliver-heger.de> wrote:
>> Hi Thomas,
>>
>> Am 30.08.2017 um 10:56 schrieb Thomas Mortagne:
>>> Here is what I currently do:
>>>
>>> PropertiesBuilderParameters parameters = new
>>> Parameters().properties();
>>> if (file.exists()) {
>>> new Parameters().properties().setFile(file);
>>> }
>>>
>>> FileBasedConfigurationBuilder builder =
>>> new
>>> FileBasedConfigurationBuilder(PropertiesConfiguration.class)
>>> .configure(parameters);
>>> PropertiesConfiguration properties = builder.getConfiguration();
>>>
>>> properties.setProperty("property", "value");
>>>
>>> builder.getFileHandler().save(file);
>>>
>>> but I find it more complex than it should.
>>
>> one option would be to create the PropertiesConfiguration directly,
>> populate it, and then save it using a FileHandler. This would roughly
>> look something like the following:
>>
>> PropertiesConfiguration config = new PropertiesConfiguration();
>> config.addProperty(...);
>>
>> FileHandler handler = new FileHandler(config);
>> File out = new File("union.properties");
>> handler.save(out);
>>
>> More information can be found in the user's guide in the section about
>> file-based configurations [1].
>>
>> HTH
>> Oliver
>>
>> [1]
>> http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#File_Operations_on_Configurations
>>
>>>
>>> IMO the file handler should not care if the file exist or not by
>>> default (empty PropertiesConfiguration as in 1.x if it does not exist)
>>> and only fail if asked to in the parameters of the builder. At the
>>> very least it should be possible to have some way to tell the builder
>>> to not care about not existing file.
>>>
>>> On Wed, Aug 30, 2017 at 10:37 AM, Thomas Mortagne
>>> <thomas.morta...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I trying to move from Commons Configuration 1.x to 2.1.1 and I cannot
>>>> figure out how to do something that used to be obvious: creating a
>>>> properties file that does not yet exist on the file system.
>>>>
>>>> In 1.x all I had to do is create a PropertiesConfiguration with a
>>>> File, set a few properties and then save.
>>>>
>>>> In 2.1.1 I cannot find how to configure the build for it to accept a
>>>> path to a file that does not exist, I always end up with:
>>>>
>>>> org.apache.commons.configuration2.ex.ConfigurationException: Could not
>>>> locate: 
>>>> org.apache.commons.configuration2.io.FileLocator@28d79cba[fileName=store.properties,basePath=/media/data/projets/xwiki/src/git/xwiki-commons/xwiki-commons-core/xwiki-commons-job/target/test/jobs/status,sourceURL=,encoding=ISO-8859-1,fileSystem=,locationStrategy=]
>>>> at 
>>>> org.apache.commons.configuration2.io.FileLocatorUtils.locateOrThrow(FileLocatorUtils.java:346)
>>>> at 
>>>> org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:972)
>>>> at 
>>>> org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:702)
>>>>
>>>> and from what I see in FileHandler sources it not really configurable.
>>>>
>>>> So did I missed something or am I really supposed to create an empty
>>>> file before using the builder ?
>>>>
>>>> Thanks,
>>>> --
>>>> Thomas
>>>
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
> 
> 
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Creating a properties file

2017-08-30 Thread Oliver Heger
Hi Thomas,

Am 30.08.2017 um 10:56 schrieb Thomas Mortagne:
> Here is what I currently do:
> 
> PropertiesBuilderParameters parameters = new
> Parameters().properties();
> if (file.exists()) {
> new Parameters().properties().setFile(file);
> }
> 
> FileBasedConfigurationBuilder builder =
> new
> FileBasedConfigurationBuilder(PropertiesConfiguration.class)
> .configure(parameters);
> PropertiesConfiguration properties = builder.getConfiguration();
> 
> properties.setProperty("property", "value");
> 
> builder.getFileHandler().save(file);
> 
> but I find it more complex than it should.

one option would be to create the PropertiesConfiguration directly,
populate it, and then save it using a FileHandler. This would roughly
look something like the following:

PropertiesConfiguration config = new PropertiesConfiguration();
config.addProperty(...);

FileHandler handler = new FileHandler(config);
File out = new File("union.properties");
handler.save(out);

More information can be found in the user's guide in the section about
file-based configurations [1].

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#File_Operations_on_Configurations

> 
> IMO the file handler should not care if the file exist or not by
> default (empty PropertiesConfiguration as in 1.x if it does not exist)
> and only fail if asked to in the parameters of the builder. At the
> very least it should be possible to have some way to tell the builder
> to not care about not existing file.
> 
> On Wed, Aug 30, 2017 at 10:37 AM, Thomas Mortagne
>  wrote:
>> Hi,
>>
>> I trying to move from Commons Configuration 1.x to 2.1.1 and I cannot
>> figure out how to do something that used to be obvious: creating a
>> properties file that does not yet exist on the file system.
>>
>> In 1.x all I had to do is create a PropertiesConfiguration with a
>> File, set a few properties and then save.
>>
>> In 2.1.1 I cannot find how to configure the build for it to accept a
>> path to a file that does not exist, I always end up with:
>>
>> org.apache.commons.configuration2.ex.ConfigurationException: Could not
>> locate: 
>> org.apache.commons.configuration2.io.FileLocator@28d79cba[fileName=store.properties,basePath=/media/data/projets/xwiki/src/git/xwiki-commons/xwiki-commons-core/xwiki-commons-job/target/test/jobs/status,sourceURL=,encoding=ISO-8859-1,fileSystem=,locationStrategy=]
>> at 
>> org.apache.commons.configuration2.io.FileLocatorUtils.locateOrThrow(FileLocatorUtils.java:346)
>> at 
>> org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:972)
>> at 
>> org.apache.commons.configuration2.io.FileHandler.load(FileHandler.java:702)
>>
>> and from what I see in FileHandler sources it not really configurable.
>>
>> So did I missed something or am I really supposed to create an empty
>> file before using the builder ?
>>
>> Thanks,
>> --
>> Thomas
> 
> 
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] save xml list element

2017-01-11 Thread Oliver Heger
Hi,

Am 11.01.2017 um 10:04 schrieb tobias.w...@t-systems.com:
> I`m reading a xml configuration object with a xml element containing a comma 
> separated string:
> 
> TLSv1.1,TLSv1.2
> 
> I archive this by setting explicitly a ListDelimiterHandler
> 
> this.xmlConfigBuilder = new 
> FileBasedConfigurationBuilder(ExtendedXMLConfiguration.class)
> 
> .configure(params.xml().setFile(configFile).setExpressionEngine(new 
> XPathExpressionEngine())
> 
> .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));
> 
> 
> and the reading is fine, but when I write this out I got separate xml 
> elements for each value instead of the same comma separated value element.
> 
> this.xmlConfigBuilder.save();
> 
> TLSv1.1
> TLSv1.2
> 

the current implementation of XMLConfiguration internally always splits
strings containing the delimiter character on reading and creates
multiple internal node objects for the single values. This is required
to handle queries correctly that operate on the internal node model. So
when writing out such a configuration the original format is lost and
multiple list nodes are created.

I would, however, assume that a change in the format only occurs if
there is a change in the value of the property or if the content of a
configuration is copied into another one. When loading an XML file the
configuration stores the original DOM and applies changes on it as
necessary. That way the original format should be kept as close as
possible. Are there such changes in your use case?

Oliver

> 
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: detecting file reload in Apache Commons Configuration2

2016-12-03 Thread Oliver Heger


Am 03.12.2016 um 16:15 schrieb Garret Wilson:
> On 12/3/2016 9:09 AM, Oliver Heger wrote:
>> ...
>> You can add an event listener at the ReloadingController, then you
>> receive notifications of type ReloadingEvent.
> 
> But how does that help me? The Javadocs for
> [ReloadingEvent](https://commons.apache.org/proper/commons-configuration/apidocs/org/apache/commons/configuration2/reloading/ReloadingEvent.html)
> says that this is an "event that is fired when a reload operation is
> required." I don't want an event just when a reload is _required_. That
> helps the ReloadingController, but doesn't help my application much. I
> want an event when a reload _has occurred_, that is, I'm guaranteed that
> the configuration now has new information.
> 
>> Alternatively, you could also register a more generic listener for
>> events on the configuration builder itself. When the builder's managed
>> configuration is reset, a corresponding event is produced. This also
>> happens during a reload operation.
> 
> Does it happen _during_ a reload operation or _after_? When I receive
> this event, is the configuration guaranteed to have the new, reloaded
> information?
> 
> Why can't I just have a simple event saying "the configuration now has
> new data"?

Maybe a misunderstanding of the reloading mechanism: New data is not
automatically pushed into a Configuration object you might have a
reference to. Rather, the configuration builder is reset. So the next
time you query the builder for a configuration you get a new one with
updated data.

When you receive one of the mentioned events the builder has been reset
and thus you know that new data is available.

Oliver

> 
> Garret
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: detecting file reload in Apache Commons Configuration2

2016-12-03 Thread Oliver Heger
Hi,

Am 02.12.2016 um 15:48 schrieb Garret Wilson:
> Using `org.apache.commons:commons-configuration2:2.1` my application
> needs to know when a configuration file has been reloaded so that it can
> update some things in the program. Apache Commons Configuration2 uses a
> lot of strategies and factories, and usually that's great, but here it's
> getting so complicated I can't figure out where I need to install a
> listener.
> 
> The application has this:
> 
> configConfigurationBuilder = new
> ReloadingFileBasedConfigurationBuilder(
> PropertiesConfiguration.class)
> .configure(new
> Parameters().properties().setFile(getConfigFile()));
> final PeriodicReloadingTrigger configReloadingTrigger = new
> PeriodicReloadingTrigger(
> configConfigurationBuilder.getReloadingController(), null, 1,
> TimeUnit.MINUTES);
> configReloadingTrigger.start();
> 
> Which of these various things can I install a listener on? I just want
> to be notified when the configuration file is reloaded.
> 
> I notice that the `ReloadingDetector` interface has a
> `reloadingPerformed()` method, and that sounds like what I want. But how
> do I add my own `ReloadingDetector`? It seems like the
> `ReloadingController` only keeps one `ReloadingDetector` around. Surely
> I don't have to subclass `ReloadingDetector` and install a custom one,
> would I? I'm not wanting to specialize the reloading detection, so
> subclassing would not be appropriate --- I just want to be notified when
> something happens. Besides, it's not obvious to me where I would even
> hook into the `ReloadingFileBasedConfigurationBuilder` chain of events
> where it uses some internal factor to create the detector.
> 
> So how can I easily get Apache Commons Configuration2 to notify me when
> it reloads a configuration?

You can add an event listener at the ReloadingController, then you
receive notifications of type ReloadingEvent.

Alternatively, you could also register a more generic listener for
events on the configuration builder itself. When the builder's managed
configuration is reset, a corresponding event is produced. This also
happens during a reload operation.

Oliver

> 
> Garret
> 
> P.S Does no one monitor Stack Overflow? It is a real pain to subscribe
> to this old-fashioned mailing list---a general one for all Apache
> Commons, at that!---just to ask a technical question. Below is the
> unanswered Stack Overflow question I posted.
> 
> http://stackoverflow.com/q/40917757/421049
> 
> If you were to answer this question on Stack Overflow it would help a
> lot more people than simply replying on this obscure mailing list. Just
> a suggestion.
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] tension between auto-loading and synchronization

2016-11-28 Thread Oliver Heger


Am 27.11.2016 um 18:14 schrieb Garret Wilson:
> Thanks for clearing this up, Oliver!
> 
> I was going straight from the documentation. On the page
> https://commons.apache.org/proper/commons-configuration/userguide/howto_concurrency.html
> I can't find anything about setting up the builder parameters.
> 
> So I'm extremely happy to learn that you can configure the builder with
> a synchronizer. So I guess the "tension" now is that part of the
> documentation says, "it's better to use a builder than the configuration
> itself, especially if you want auto-loading", and then the part that
> actually talks about synchronization seems to favor working with the
> configuration and doesn't even mention that I can set the synchronizer
> on the builder.
> 
> At the very least
> https://commons.apache.org/proper/commons-configuration/userguide/howto_concurrency.html
> should mention the configuration params.

I will try to make it clearer.

Oliver

> 
> Cheers,
> 
> Garret
> 
> 
> On 11/27/2016 8:58 AM, Gary Gregory wrote:
>>
>> Do we need better Javadocs to make this obvious?
>>
>> Gary
>>
>>
>> On Nov 27, 2016 7:02 AM, "Oliver Heger" <oliver.he...@oliver-heger.de
>> <mailto:oliver.he...@oliver-heger.de>> wrote:
>>
>> Hi,
>>
>> Am 25.11.2016 um 22:55 schrieb Garret Wilson:
>>
>> I'm reading the documentation for the new
>> commons-configuration 2.x. I
>> have a simple need: load a configuration file from a
>> properties file,
>> reload it when the file changes, and make the configuration
>> thread-safe
>> for reading.
>>
>> From the documentation I understand that I shouldn't keep the
>> Configuration object around, because it may be reloaded if the
>> file
>> changes. Instead I should keep a ConfigurationBuilder around.
>> So my
>> application's getConfiguration() would look like this:
>>
>> public Configuration getConfiguration() {
>>   return configurationBuilder.getConfiguration();
>> }
>>
>> But I need it to be thread-safe. So I do this:
>>
>> public Configuration getConfiguration() {
>>   Configuration
>> configuration=configurationBuilder.getConfiguration();
>>   configuration.setSynchronizer(new ReadWriteSynchronizer());
>>   return configuration;
>> }
>>
>> Oops! It turns out that we don't know if the builder returns
>> the same
>> configuration or a new configuration, so we could be swapping
>> out the
>> synchronizer on the same configuration. That introduces a race
>> condition
>> and defeats the thread safety!
>>
>> So are we expected to keep a separate synchronizer around and
>> make sure
>> the new/existing configuration uses it?
>>
>> private final Synchronizer synchronizer = new
>> ReadWriteSynchronizer();
>>
>> public Configuration getConfiguration() {
>>   Configuration
>> configuration=configurationBuilder.getConfiguration();
>>   configuration.setSynchronizer(synchronizer);
>>   return configuration;
>> }
>>
>> Wow, that's getting complicated. The problem is that Apache
>> Commons
>> Configuration2 recommends that the builder be the ultimate
>> source of the
>> configuration, yet it associates the syncrhonizer with the actual
>> configuration instance. Shouldn't we set the synchronizer on
>> the builder
>> and let it manage the synchronizer of the new configurations?
>> Or do you
>> want each configuration to potentially have different
>> synchronizers? But
>> is that realistic---would synchronized and unsynchronized
>> configurations
>> play well together if they are backed by the same builder? I'm
>> trying to
>> understand what the expected usage is.
>>
>>
>> you configure the builder to set the correct synchronizer on newly
>> created Configuration objects. To achieve this, call the builder's
>> configure() method with a parameters object. Focused on the
>> synchronizer, this looks as follows:
>>
>> Synchronizer sync = ...;
>> Parameters params = new Parameters();
>

Re: [configuration] tension between auto-loading and synchronization

2016-11-27 Thread Oliver Heger

Hi,

Am 25.11.2016 um 22:55 schrieb Garret Wilson:

I'm reading the documentation for the new commons-configuration 2.x. I
have a simple need: load a configuration file from a properties file,
reload it when the file changes, and make the configuration thread-safe
for reading.

From the documentation I understand that I shouldn't keep the
Configuration object around, because it may be reloaded if the file
changes. Instead I should keep a ConfigurationBuilder around. So my
application's getConfiguration() would look like this:

public Configuration getConfiguration() {
  return configurationBuilder.getConfiguration();
}

But I need it to be thread-safe. So I do this:

public Configuration getConfiguration() {
  Configuration configuration=configurationBuilder.getConfiguration();
  configuration.setSynchronizer(new ReadWriteSynchronizer());
  return configuration;
}

Oops! It turns out that we don't know if the builder returns the same
configuration or a new configuration, so we could be swapping out the
synchronizer on the same configuration. That introduces a race condition
and defeats the thread safety!

So are we expected to keep a separate synchronizer around and make sure
the new/existing configuration uses it?

private final Synchronizer synchronizer = new ReadWriteSynchronizer();

public Configuration getConfiguration() {
  Configuration configuration=configurationBuilder.getConfiguration();
  configuration.setSynchronizer(synchronizer);
  return configuration;
}

Wow, that's getting complicated. The problem is that Apache Commons
Configuration2 recommends that the builder be the ultimate source of the
configuration, yet it associates the syncrhonizer with the actual
configuration instance. Shouldn't we set the synchronizer on the builder
and let it manage the synchronizer of the new configurations? Or do you
want each configuration to potentially have different synchronizers? But
is that realistic---would synchronized and unsynchronized configurations
play well together if they are backed by the same builder? I'm trying to
understand what the expected usage is.


you configure the builder to set the correct synchronizer on newly 
created Configuration objects. To achieve this, call the builder's 
configure() method with a parameters object. Focused on the 
synchronizer, this looks as follows:


Synchronizer sync = ...;
Parameters params = new Parameters();
BasicConfigurationBuilder builder =
new BasicConfigurationBuilder(
PropertiesConfiguration.class)
.configure(params.basic()
.setSynchronizer(sync));

Just insert your type parameters for the configuration type. All 
properties configured this way are automatically set on the 
Configuration each time a new instance is created.


Oliver



Garret

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Custom variable interpolation

2016-11-23 Thread Oliver Heger
Hi Greg,

Am 23.11.2016 um 00:50 schrieb Greg Torrance:
> Hi all,
> 
> I would like to implement a custom variable interpolator that is
> specific to a Configuration object, but that also supports the standard
> prefixes (sys, const, env).
> 
> What I mean by "specific to a Configuration object" is that the custom
> interpolator needs to know the Configuration to which it is associated
> in order to produce a valid result for a variable.
> 
> Say I want to associate a variable "rootDir" with the custom prefix
> "myPrefix". To use this variable I would specify ${myPrefix:rootDir} in
> my configuration file. At the code level, though, if I create a
> Configuration config1, I want "rootDir" for that Configuration to
> evaluate to "/abc/def". But for Configuration config2, "rootDir" should
> evaluate to "/ghi/jkl". I assume I will need to have a specific Lookup
> instance per Configuration, right?
> 
> I have tried to understand how to do this based on this page
> (https://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#Customizing_interpolation),
> but the information seems to be a bit inaccurate based on v2.1. (For
> example, it refers to calling the static registerGlobalLookup() method
> on ConfigurationInterpolator, but this method does not appear to exist.)

Could you please open a ticket in our bugtracking system [1] when you
notice inconsistencies in the documentation, so that they can be fixed?
Thanks in advance!

[1]
https://commons.apache.org/proper/commons-configuration/issue-tracking.html

> 
> Also, I'm not clear if I should be extending StrLookup, or implementing
> Lookup. (I was initially using StrLookup, but the
> ConfigurationInterpolator registerLookup() method requires a Lookup
> instance.)

StrLookup is from [lang], to avoid a direct dependency, [configuration]
uses its own abstraction. But the Lookup interface is so simple that it
can be easily implemented.

> 
> If I do the following, it seems to allow me create a working custom
> interpolator. But when I do this, the standard prefixes (sys, const,
> env) no longer work:
> 
> ConfigurationInterpolator ci = new ConfigurationInterpolator();
> ci.registerLookup("myPrefix", new MyLookup()); // implementation of
> Lookup interface
> config1.setInterpolator(ci);

You can try the following:
config1.getInterpolator().registerLookup( ... );

This should add the new lookup to the existing ones.

Oliver

> 
> Any thoughts on how to implement this using Commons Configuration best
> practices?
> 
> Thanks in advance,
> Greg
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Character position of key in file

2016-11-15 Thread Oliver Heger
Hi Greg,

Am 14.11.2016 um 22:34 schrieb Greg Torrance:
> Thanks Oliver.
> 
> Regarding the Configuration API, is it possible to replace not just
> values but keys, too? For example, could I replace
> 
> 
> 
> with
> 
> 
>
>   Some Value
>
> 
> 
> If so, can you suggest what class to look at first (for accomplishing
> this)?

This is indeed a tough one. There are multiple options, but I am not
sure whether they fully cover your use case; you will certainly need
some experiments:

- With the high-level API (offered by Configuration) you can delete the
key to be replaced and then use the addNodes() method to insert a nodes
structure as replacement. The tricky part is to get the key for
addNodes() right, so the replacement goes to the desired position. The
configuration's expression engine may help you here. It has methods to
query for keys (and receive matching node objects) and to obtain a
canonical key for a given node.

- You may also operate on the hierarchical configuration's node
structure directly. The root node can be queried via the node model
getNodeModel()). As this structure is immutable, you cannot directly
change it, but you have to create a copy which might not be that efficient.

- Unfortunately, XMLConfiguration has no direct hooks to manipulate the
node creation process. There are some helper methods, but these are private.

The use case is interesting. It would be good to offer some generic
support for configuration pre-processing, independent on a concrete
implementation. However, this is probably not easy to implement, and it
may still be insufficient for specific use cases.

Oliver

> 
> Thanks,
> Greg
> 
> On 11/14/2016 04:27 PM, Oliver Heger wrote:
>> Hi Greg,
>>
>> Am 14.11.2016 um 19:01 schrieb Greg Torrance:
>>> I hope I'm not asking too many questions...
>>>
>>> I wonder if it is possible to determine the character/byte position
>>> of a particular key in a configuration file?
>> No, the original position from where data is read is not stored in the
>> resulting configuration.
>>
>>> My intent is to do a pre-pass of an XML configuration file in which
>>> certain configuration keys/values are replaced by other keys/values.
>>> Once that is done the file will be reloaded. I realize this is
>>> possible outside of Commons Configuration, but I was wondering if
>>> there is a "hook" in the tool that might help simplify the process.
>>>
>> But wouldn't it be easier to do this with the Configuration API? Load
>> the configuration, iterate over its keys, replace data as appropriate
>> and save the result?
>>
>> Oliver
>>
>>> Thanks,
>>> Greg
>>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Character position of key in file

2016-11-14 Thread Oliver Heger
Hi Greg,

Am 14.11.2016 um 19:01 schrieb Greg Torrance:
> I hope I'm not asking too many questions...
> 
> I wonder if it is possible to determine the character/byte position of a 
> particular key in a configuration file?
No, the original position from where data is read is not stored in the
resulting configuration.

> 
> My intent is to do a pre-pass of an XML configuration file in which certain 
> configuration keys/values are replaced by other keys/values. Once that is 
> done the file will be reloaded. I realize this is possible outside of Commons 
> Configuration, but I was wondering if there is a "hook" in the tool that 
> might help simplify the process.
> 
But wouldn't it be easier to do this with the Configuration API? Load
the configuration, iterate over its keys, replace data as appropriate
and save the result?

Oliver

> Thanks,
> Greg
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Combined Configuration examples

2016-11-14 Thread Oliver Heger
Hi Aaron,

Am 14.11.2016 um 18:38 schrieb Aaron Gadberry:
> Hi All,
> 
> A follow up question.  Is there a way to view the combined XML?  I am
> constantly missing elements not knowing if it is my paths or my original
> files or the combiner.

what you could do is to copy the combined configuration into a
XMLConfiguration and save this to a file. XMLConfiguration has a
constructor that accepts a hierarchical configuration; so you pass in
the combined configuration. Then the configuration can be saved to file
or dumped to an output stream:

XMLConfiguration copy = new XMLConfiguration(combined);
FileHandler handler = new FileHandler(copy);
handler.save(new File("target.xml"));

Oliver

> 
> Thanks,
> 
> 
> 
> On Sun, Nov 13, 2016 at 2:54 PM, Greg Torrance <greg.torra...@pobox.com>
> wrote:
> 
>> Thanks Oliver.
>>
>> I think I understand what you're saying about why Channel 4 would not be
>> included with the OverrideCombiner (if it doesn't exist in testfile1.xml).
>> I am sorry to hear, though, that attributes are not used at all for
>> matching with OverrideCombiner. If I'm understanding it correctly, that
>> means it can't really be used for overriding just specific list items, as
>> the entire list would have to be represented, in the same order, in both
>> primary and overriding files, or the wrong list item might be overridden.
>> (For example, if the primary list had Channels 1, 2, and 3, and the
>> override list had only Channel 2, then it would attempt to override Channel
>> 1 with the info from Channel 2.) Is my understanding correct?
>>
>> Anyway, I'm going to experiment a bit and try to make sure I have a good
>> understanding of how this works.
>>
>> Thanks again for the help.
>>
>> Greg
>>
>>
>> On 11/13/2016 01:51 PM, Oliver Heger wrote:
>>
>>> Hi Greg,
>>>
>>> Am 13.11.2016 um 18:41 schrieb Greg Torrance:
>>>
>>>> Hi Oliver,
>>>>
>>>> Thanks for the reply. That is helpful!
>>>>
>>>> Hm, it looks as if the examples are partly incorrect. I assume that
>>>>>
>>>> the channel with id="4" should not be part of testfile1.xml, but only be
>>>> contained in the second file. It should appear in the results of union
>>>> and  merge combiner. Does that make sense?
>>>>
>>>> I'm not clear why -- if the channel with id="4" is not contained in
>>>> testfile1.xml -- why it will not end up in the results from all three
>>>> combiners. Why just union and merge and not override, too?
>>>>
>>> On a higher level, OverrideCombiner detects that both files have a list
>>> of channels. Therefore, it copies the first list and ignores the second
>>> one. So the channels element in the first file overrides the one in the
>>> second file.
>>>
>>> As for the attributes, do I understand correctly that the attribute
>>>> values for elements are used, essentially, as "key" values to
>>>> distinguish the various elements for combining purposes? And if the
>>>> values of any attributes of two elements differ, then the elements would
>>>> be considered different elements for combining purposes? (Said another
>>>> way, if two elements have a set of attributes in common, if the values
>>>> for those common attributes are the same, the elements will be
>>>> considered to match.) Does that make sense? Is that correct?
>>>>
>>> This is true only for MergeCombiner. The other combiners do not try to
>>> match nodes in both configurations based on their attribute values; they
>>> take two source nodes at the same position in the hierarchy and produce
>>> a result node that has all the attributes of the two source nodes.
>>>
>>> Oliver
>>>
>>> Thanks again for the reply.
>>>>
>>>> Greg
>>>>
>>>> On 11/13/2016 12:05 PM, Oliver Heger wrote:
>>>>
>>>>> Hi Greg,
>>>>>
>>>>> Am 13.11.2016 um 15:07 schrieb Greg Torrance:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I am trying to work out the precise differences between
>>>>>> OverrideCombiner, UnionCombiner, and MergeCombiner. However, the
>>>>>> examples on this page
>>>>>> (https://commons.apache.org/proper/commons-configuration/use
>>>>>> rguide/howto_combinedconfiguration.html)
>>>>>>

Re: [configuration] reading full text of PropertiesConfiguration file in 2.0

2016-11-14 Thread Oliver Heger
Hi Robert,

Am 12.11.2016 um 03:47 schrieb Robert V Sasseen:
> Is there a straightforward way to get the full text of the properties file 
> from a PropertiesConfiguration object in 2.0? In 1.x I could do
> 
> 
> PropertiesConfiguration propertiesConfiguration = new 
> PropertiesConfiguration("my.properties");
> 
> URL url = propertiesConfiguration.getURL();
> String cont = IOUtils.toString((InputStream) 
> url.openConnection().getContent(), StandardCharsets.UTF_8);
> 
> 
> This worked for both properties file in my jar and in the filesystem on the 
> classpath. But in 2.0 PropertiesConfiguration does not have a method getURL().
> 
> 
> Since PropertiesConfiguration has a (somewhat) complicated algorithm for 
> finding properties in the classpath and filesystem, I want to let it carry 
> out its algorithm, then ask it where it found the file, rather than having to 
> try to understand and replicate the algorithm.
> 
> 
> If you're wondering why I want the text, I want to be able to show my user 
> exactly what the file looks like, even if it's hidden away in a jar file. I 
> know (a little) about PropertiesConfigurationLayout, but I'd prefer to just 
> get the file text rather than reconstruct an approximation of it using that.
> 
If you use a FileBasedConfigurationBuilder to create the
PropertiesConfiguration, you should be able to use the builder's
getFileHandler() method to obtain a FileHandler object. This object has
methods that allow you to retrieve the underlying file or URL.

Oliver

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Combined Configuration examples

2016-11-13 Thread Oliver Heger
Hi Greg,

Am 13.11.2016 um 18:41 schrieb Greg Torrance:
> Hi Oliver,
> 
> Thanks for the reply. That is helpful!
> 
>> Hm, it looks as if the examples are partly incorrect. I assume that
> the channel with id="4" should not be part of testfile1.xml, but only be
> contained in the second file. It should appear in the results of union
> and  merge combiner. Does that make sense?
> 
> I'm not clear why -- if the channel with id="4" is not contained in
> testfile1.xml -- why it will not end up in the results from all three
> combiners. Why just union and merge and not override, too?
On a higher level, OverrideCombiner detects that both files have a list
of channels. Therefore, it copies the first list and ignores the second
one. So the channels element in the first file overrides the one in the
second file.

> 
> As for the attributes, do I understand correctly that the attribute
> values for elements are used, essentially, as "key" values to
> distinguish the various elements for combining purposes? And if the
> values of any attributes of two elements differ, then the elements would
> be considered different elements for combining purposes? (Said another
> way, if two elements have a set of attributes in common, if the values
> for those common attributes are the same, the elements will be
> considered to match.) Does that make sense? Is that correct?
This is true only for MergeCombiner. The other combiners do not try to
match nodes in both configurations based on their attribute values; they
take two source nodes at the same position in the hierarchy and produce
a result node that has all the attributes of the two source nodes.

Oliver

> 
> Thanks again for the reply.
> 
> Greg
> 
> On 11/13/2016 12:05 PM, Oliver Heger wrote:
>> Hi Greg,
>>
>> Am 13.11.2016 um 15:07 schrieb Greg Torrance:
>>> Hi all,
>>>
>>> I am trying to work out the precise differences between
>>> OverrideCombiner, UnionCombiner, and MergeCombiner. However, the
>>> examples on this page
>>> (https://commons.apache.org/proper/commons-configuration/userguide/howto_combinedconfiguration.html)
>>>
>>> are confusing to me.
>>>
>>> testfile1.xml and testfile2.xml both contain Channels with id="4",
>>> however none of the Combiner Results shows any Channels with id="4".
>>> And the Notes on the right-hand side of the page contain no mention of
>>> Channel 4.
>>>
>>> Am I missing something? Are the examples correct?
>> Hm, it looks as if the examples are partly incorrect. I assume that the
>> channel with id="4" should not be part of testfile1.xml, but only be
>> contained in the second file. It should appear in the results of union
>> and merge combiner. Does that make sense?
>>
>>> What I'm really trying to understand is the impact of attributes in the
>>> way the various combiners choose to combine elements. (Any pointers to
>>> further documentation on this would be appreciated.)
>> Some more information can be found in the Javadocs of the combiner
>> classes:
>> - UnionCombiner states: "Another limitation is the handling of
>> attributes: Attributes can only have a single value. So if two nodes are
>> to be combined which both have an attribute with the same name, it is
>> not possible to construct a proper union attribute. In this case, the
>> attribute value from the first node is used."
>>
>> - OverrideCombiner has an addAttributes() method with the following
>> documentation: "Handles the attributes during a combination process.
>> First all attributes of the first node are added to the result. Then all
>> attributes of the second node, which are not contained in the first
>> node, are also added."
>>
>> - The merging behavior of MergeCombiner is also described in its class
>> documentation.
>>
>> Does this help?
>> Oliver
>>
>>> Thoughts?
>>>
>>> Thanks,
>>> Greg
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>> For additional commands, e-mail: user-h...@commons.apache.org
>>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Combined Configuration examples

2016-11-13 Thread Oliver Heger
Hi Greg,

Am 13.11.2016 um 15:07 schrieb Greg Torrance:
> Hi all,
> 
> I am trying to work out the precise differences between
> OverrideCombiner, UnionCombiner, and MergeCombiner. However, the
> examples on this page
> (https://commons.apache.org/proper/commons-configuration/userguide/howto_combinedconfiguration.html)
> are confusing to me.
> 
> testfile1.xml and testfile2.xml both contain Channels with id="4",
> however none of the Combiner Results shows any Channels with id="4". 
> And the Notes on the right-hand side of the page contain no mention of
> Channel 4.
> 
> Am I missing something? Are the examples correct?
Hm, it looks as if the examples are partly incorrect. I assume that the
channel with id="4" should not be part of testfile1.xml, but only be
contained in the second file. It should appear in the results of union
and merge combiner. Does that make sense?

> 
> What I'm really trying to understand is the impact of attributes in the
> way the various combiners choose to combine elements. (Any pointers to
> further documentation on this would be appreciated.)
Some more information can be found in the Javadocs of the combiner classes:
- UnionCombiner states: "Another limitation is the handling of
attributes: Attributes can only have a single value. So if two nodes are
to be combined which both have an attribute with the same name, it is
not possible to construct a proper union attribute. In this case, the
attribute value from the first node is used."

- OverrideCombiner has an addAttributes() method with the following
documentation: "Handles the attributes during a combination process.
First all attributes of the first node are added to the result. Then all
attributes of the second node, which are not contained in the first
node, are also added."

- The merging behavior of MergeCombiner is also described in its class
documentation.

Does this help?
Oliver

> 
> Thoughts?
> 
> Thanks,
> Greg
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [Configuration]

2016-08-24 Thread Oliver Heger
Hi,

Am 24.08.2016 um 21:31 schrieb Michael Fortin:
> Hi, I’m trying to combine two child lists in two configurations and was 
> expecting them to be combined into one longer list, but one seems to be 
> taking precedence over the other.  Is there a way to merge child lists?

Don't use CompositeConfiguration, but CombinedConfiguration. Please
refer to the user guide [1] and make sure you read the chapter about
node combiners.

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedconfiguration.html#Combined_Configuration

> 
> Here’s the unit test:
> https://github.com/m410/commons-configuration-yaml/blob/master/src/test/java/org/m410/config/YamlCompositeConfigurationTest.java
>  
> 
> line 48 fails
> 
> here’s the two configurations:
> https://github.com/m410/commons-configuration-yaml/tree/master/src/test/resource
>  
> 
> 
> thx
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.1 Released

2016-08-21 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.1.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

This is the first maintenance release for Apache Commons Configuration
2.x. It contains some bug fixes and also adds a few new features like a
better integration into Spring. A full list of all changes can be found
in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

Version 2.1 is fully source and binary compatible with the previous 2.0
version.

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

Please verify signatures using the KEYS file available at the above
location when downloading the release.

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: XInclude Support

2016-05-18 Thread Oliver Heger
Hi Aaron,

thanks for sharing this!

Oliver

Am 17.05.2016 um 16:34 schrieb Aaron Gadberry:
> Hi,
> 
> To answer my own question, the document builder I was using was not
> namespace or xinclude aware.  Acquiring a document builder manually and
> setting a custom document builder on the XMLConfiguration allowed XInclude
> to function as intended.
> 
> Here is the updated and functional code and output.
> 
> package test;
> 
> import java.io.File;
> 
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.parsers.ParserConfigurationException;
> 
> import org.apache.commons.configuration2.ConfigurationUtils;
> import org.apache.commons.configuration2.XMLConfiguration;
> import
> org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
> import org.apache.commons.configuration2.builder.fluent.Parameters;
> import org.apache.commons.configuration2.ex.ConfigurationException;
> 
> public class TestConfiguration {
> public static void main(String[] args) throws ConfigurationException {
> try {
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setXIncludeAware(true);
> dbf.setNamespaceAware(true);
> DocumentBuilder db = dbf.newDocumentBuilder();
> Parameters params = new Parameters();
> FileBasedConfigurationBuilder builder = new
> FileBasedConfigurationBuilder(
> XMLConfiguration.class);
> builder.configure(params.xml()
> .setFile(new File("configs/test_external.xml"))
> .setDocumentBuilder(db));
> XMLConfiguration config = builder.getConfiguration();
> System.out.println(ConfigurationUtils.toString(config));
> } catch (ParserConfigurationException e) {
> e.printStackTrace();
> }
> 
> }
> }
> 
> 
> New Output:
> 
> [@xmlns:xi]=http://www.w3.org/2001/XInclude
> ExternalElements.InternalRoot[@xml:base]=test_internal.xml
> ExternalElements.InternalRoot.InternalElement[@name]=[1, 2, 3]
> 
> 
> Thanks!
> 
> 
> On Tue, May 17, 2016 at 8:06 AM, Aaron Gadberry  wrote:
> 
>> Hi,  My question is specifically on commons-configuration2.
>>
>> I cannot seem to use XInclude within an XMLConfiguration file.  Perhaps I
>> am doing something incorrectly, or perhaps it is unsupported, but I can't
>> seem to find documentation either way.
>>
>> This is my example program, files and output.
>>
>> TestConfiguration.java
>>
>> package test;
>>
>> import java.io.File;
>>
>> import org.apache.commons.configuration2.ConfigurationUtils;
>> import org.apache.commons.configuration2.XMLConfiguration;
>> import
>> org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
>> import org.apache.commons.configuration2.builder.fluent.Parameters;
>> import org.apache.commons.configuration2.ex.ConfigurationException;
>>
>> public class TestConfiguration {
>> public static void main(String[] args) throws ConfigurationException {
>> Parameters params = new Parameters();
>> FileBasedConfigurationBuilder builder = new
>> FileBasedConfigurationBuilder(
>> XMLConfiguration.class);
>> builder.configure(params.fileBased().setFile(
>> new File("configs/test_external.xml")));
>> XMLConfiguration config = builder.getConfiguration();
>> System.out.println(ConfigurationUtils.toString(config));
>> }
>> }
>>
>>
>> configs/test_external.xml
>>
>> 
>> 
>> 
>> http://www.w3.org/2001/XInclude;
>> href="configs/test_internal.xml" />
>> 
>> 
>>
>>
>> configs/test_internal.xml
>>
>> 
>> 
>> 
>> 
>> 
>> 
>>
>>
>> Result:
>>
>> ExternalElements.xi:include[@xmlns:xi]=http://www.w3.org/2001/XInclude
>> ExternalElements.xi:include[@href]=configs/test_internal.xml
>>
>>
>> Expected Result:
>>
>> ExternalElements.InternalRoot.InternalElement[@name]=1,2,3
>>
>>
>> Any help is appreciated!
>>
>> Thanks,
>>
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration2]: AbstractConfiguration::getArray

2016-04-29 Thread Oliver Heger


Am 29.04.2016 um 20:36 schrieb Jörg Schaible:
> c...@honton.org wrote:
> 
>> Jorge,
>>
>> You could create a different named method for each primitive array
>> type.  Would be a pain to use in a generic fashion.
> 
> 
> [snip]
> 
> I agree with a method returning explicitly an array, but that has been 
> nonsense in first place.
> 
> As I already pointed out, the existing
> 
>   T get(Class cls, String key);
> 
> would have been completely enough. See my examples from the last mail.

IIRC get() currently cannot handle arrays, but this should be easy to
add. So could you please open a Jira ticket to track this?

Thanks
Oliver

> 
> Cheers,
> Jörg
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration2]: AbstractConfiguration::getArray

2016-04-28 Thread Oliver Heger
Hi Jörg,

Am 28.04.2016 um 16:34 schrieb Jörg Schaible:
> Chas Honton wrote:
> 
>> Try casting Object[] to long[]. The compiler and the runtime will
>> complain.
> 
> It is not about a cast, it's about returning the proper object. And it has 
> nothing to do with primitives, because you cannot cast e.g. Object[] to 
> String[] either.

my first idea was the generic version, too. However, as Chas said, it is
not possible to make a method with such a signature return an array of
primitives. After type erasure, you have

public Object[] toArray(Class cls, String key)

and a primitive array is not an Object[].

Oliver

> 
>>
>>> On Apr 27, 2016, at 11:59 PM, Jörg Schaible
>>> <joerg.schai...@bpm-inspire.com> wrote:
>>>
>>> Hi Oliver,
>>>
>>> Oliver Heger wrote:
>>>
>>>> Hi Rainer,
>>>>
>>>>> Am 27.04.2016 um 21:22 schrieb Rainer Hirschmiller:
>>>>> Hi.
>>>>>
>>>>> I wonder why AbstractConfiguration::getArray(cls, key) returns a single
>>>>> object, not an array of objects? Can somebody explain why the caller
>>>>> have to make an explicit cast?
>>>>>
>>>>> e.g.
>>>>> AbstractConfiguration  = ;
>>>>>
>>>>> Object obj = configuration.getArray(String.class, "key);
>>>>> // expected Object[] obj = configuration.getArray(String.class, "key);
>>>>
>>>> the explanation can be found in the Javadocs of the ConversionHandler
>>>> interface which is used behind the scenes. Citing from the docs of the
>>>> toArray() method:
>>>>
>>>> "Note that the result type of this method is Object; because this method
>>>> can also produce arrays of a primitive type the return type Object[]
>>>> cannot be used."
>>>
>>> That does not explain, why the method is not declared using generics:
>>>
>>>  public  T[] toArray(Class cls, String key);
>>>
>>> Cheers,
>>> Jörg
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>> For additional commands, e-mail: user-h...@commons.apache.org
>>>
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Monitoring configs

2016-04-25 Thread Oliver Heger


Am 25.04.2016 um 09:45 schrieb Ahmad, Zeba:
> Hi,
> 
> I'm looking at providing a platform for users to monitor their configurations 
> either via JMX or some other means. Some ways I can think of doing this
> 
> 1)  Let users register their chosen configurations as MBeans. 
> Here's
>  a similar approach by Netflix. Here however, platform cannot mandate all 
> configurations to get surfaced for monitoring.
> 
> 2)  Read all config files present for the given application in config 
> directory, use Apache Modeler or some other to dynamically generate bean 
> descriptors and JMX MBeans for monitoring. But here I'm duplicating the 
> reading of the configs and the memory structures.
> 
> 3)  Have instrumentation within apache-commons-config  for such 
> monitoring by JMX or any other means.
> 
> Reg. #3, is there any recommendation on how users can efficiently 
> monitor/view/modify their configurations dynamically (without delivering an 
> updated file)?

Not sure what you want to achieve exactly. Could the event mechanism [1]
be of some help?

Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_events.html#Events

> 
> Regards,
> Zeba
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] use commons configuration 2 as PropertySource in Spring

2016-04-20 Thread Oliver Heger
Hi Dennis,

Am 19.04.2016 um 22:05 schrieb Dennis Kieselhorst:
> Hi Gary,
> 
> I'm Apache committer and like to contribute but do you think it makes
> sense to have a Spring dependency in Commons Configuration? Maybe as
> optional?

obviously, there is no better active project where this Spring-related
code could live. So I guess, an optional dependency would probably be okay.

On the dependencies page all optional dependencies are listed and also
for which use cases they are required. So this information would need to
be updated, too.

Thanks
Oliver

> 
> Regards
> Dennis
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Composite Configuration with ReloadingFileBasedConfiguration

2016-04-20 Thread Oliver Heger
Hi Avin,

the reloading is only performed by the configuration builder. After you
have obtained a configuration from the builder, it will not change
automatically due to a reload operation. Citing from the user's guide [1]:

"One important point to keep in mind when using this approach to
reloading is that reloads are only functional if the builder is used as
central component for accessing configuration data. The configuration
instance obtained from the builder will not change automagically! So if
an application fetches a configuration object from the builder at
startup and then uses it throughout its life time, changes on the
external configuration file become never visible. The correct approach
is to keep a reference to the builder centrally and obtain the
configuration from there every time configuration data is needed."

This section of the user's guide also contains a working example. If you
want to combine multiple configuration sources with reloading support,
use CombinedConfiguration rather than CompositeConfiguration. How this
is done is described at [2].

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
[2]
http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedbuilder.html#Reloading_Support

Am 20.04.2016 um 05:10 schrieb Avin:
> I am trying to implement the Apache Configuration 2 in my codebaseimport 
> java.io.File;
> import java.util.concurrent.TimeUnit;
> 
> import org.apache.commons.configuration2.PropertiesConfiguration;
> import org.apache.commons.configuration2.builder.ConfigurationBuilderEvent;
> import 
> org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder;
> import org.apache.commons.configuration2.builder.fluent.Parameters;
> import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
> import org.apache.commons.configuration2.event.EventListener;
> import org.apache.commons.configuration2.ex.ConfigurationException;
> import org.apache.commons.configuration2.reloading.PeriodicReloadingTrigger;
> 
> import org.apache.commons.configuration2.CompositeConfiguration;
> 
> public class Test {
> 
> private static final long DELAY_MILLIS = 10 * 60 * 5;
> 
> 
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> CompositeConfiguration compositeConfiguration = new 
> CompositeConfiguration();
> PropertiesConfiguration props = null;
> try {
> props = initPropertiesConfiguration(new 
> File("/tmp/DEV.properties"));
> } catch (ConfigurationException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> compositeConfiguration.addConfiguration( props );
> compositeConfiguration.addEventListener(ConfigurationBuilderEvent.ANY,
> new EventListener()
> {
> @Override
> public void onEvent(ConfigurationBuilderEvent event)
> {
> System.out.println("Event:" + event);
> 
> }
> });
> 
> System.out.println(compositeConfiguration.getString("property1"));
> 
> try {
> Thread.sleep(14*1000);
> } catch (InterruptedException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> 
> // Have a script which changes the value of property1 in 
> DEV.properties
> System.out.println(compositeConfiguration.getString("property1"));
> }
> 
> protected static PropertiesConfiguration initPropertiesConfiguration(File 
> propsFile) throws ConfigurationException { 
> 
> if(propsFile.exists()) {
> 
> final 
> ReloadingFileBasedConfigurationBuilder builder =
> new 
> ReloadingFileBasedConfigurationBuilder(PropertiesConfiguration.class)
> .configure(new Parameters().fileBased()
> .setFile(propsFile)
> .setReloadingRefreshDelay(DELAY_MILLIS)
> .setThrowExceptionOnMissing(false)
> .setListDelimiterHandler(new 
> DefaultListDelimiterHandler(';')));
> final PropertiesConfiguration propsConfiguration = 
> builder.getConfiguration();
> PeriodicReloadingTrigger trigger = new 
> PeriodicReloadingTrigger(builder.getReloadingController(),
> null, 1, TimeUnit.SECONDS);
> trigger.start();
> 
> return propsConfiguration;
> } else {
> return new PropertiesConfiguration();
> }
> 
> }
> }
> Here is a sample code that I using to check whether the Automatic Reloading 
> works or not. However when the underlying property file is updated, the 
> configuration doesn't reflect it.Once the DEV.properties is updated, it 
> doesn't get 

Re: [configuration] read only configuration with combined configurations

2016-04-14 Thread Oliver Heger


Am 14.04.2016 um 04:46 schrieb Mansour Al Akeel:
> Oliver,
> thank you a lot for the detailed response.
> What I concluded that I need a wrapper. We need to have a repository
> of configurations for a unit testing framework (think JUnit).
> We have a setup method, then test cases. So here's what we need:
> 
> 1- A section of the configurations (read-only), holds process wide
> configurations, and loaded on start up.
> 2- A section for setup (read-only) config, loaded from files
> 3- A section for setup method (read/write), that turns becomes
> read-only after the setup method exits. For example store a login
> token, or similar properties.
> 4- A section for data provided by files for each test case. This is
> read only. This is erased after each test method.
> 5- A section for read-write test data, that gets erased after each test 
> method.
> 
> Immutable configurations here will complicate things for me. I think
> it's better to stay with CombinedConfigurations, and write a
> wrapper/proxy that will control access, and manage the repository.
Yes, this sounds reasonable. Good luck!

Oliver

> 
> Thank you a lot for your help.
> 
> 
> On Tue, Apr 12, 2016 at 3:28 PM, Oliver Heger
> <oliver.he...@oliver-heger.de> wrote:
>> Hi Mansour,
>>
>> Am 12.04.2016 um 05:39 schrieb Mansour Al Akeel:
>>> Hello,
>>>
>>> I am looking to create a configuration repository, with multiple part,
>>> some for read-only, other for read. I found combined configuration
>>> suitable for my other requirements, but I was not able to add this mix
>>> of read-only and read/write configurations.
>>
>> I am not sure how exactly your configuration repository looks like and
>> which API it provides.
>>
>> I would recommend the following approach: Use a CombinedConfiguration to
>> manage all your configuration settings. This configuration should be
>> treated as immutable, e.g. convert it using
>> ConfigurationUtils.unmodifiableConfiguration() when exposing it to
>> clients. Although CombinedConfiguration has methods for updating
>> properties, these capabilities are limited (see [1]).
>>
>> Your repository component should offer means for querying or updating
>> the configurations that can be modified. When adding configurations to
>> the combined configuration you can specify names under which these child
>> configurations can be accessed; you can use this mechanism to obtain
>> references to specific child configurations that can then be updated.
>> When a child configuration is manipulated, the combined configuration is
>> automatically updated accordingly.
>>
>> Would this work for you?
>>
>> Oliver
>>
>> [1]
>> http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedconfiguration.html#Dealing_with_changes
>>
>>>
>>> Any hint ?
>>>
>>> Thank you.
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>>> For additional commands, e-mail: user-h...@commons.apache.org
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] read only configuration with combined configurations

2016-04-12 Thread Oliver Heger
Hi Mansour,

Am 12.04.2016 um 05:39 schrieb Mansour Al Akeel:
> Hello,
> 
> I am looking to create a configuration repository, with multiple part,
> some for read-only, other for read. I found combined configuration
> suitable for my other requirements, but I was not able to add this mix
> of read-only and read/write configurations.

I am not sure how exactly your configuration repository looks like and
which API it provides.

I would recommend the following approach: Use a CombinedConfiguration to
manage all your configuration settings. This configuration should be
treated as immutable, e.g. convert it using
ConfigurationUtils.unmodifiableConfiguration() when exposing it to
clients. Although CombinedConfiguration has methods for updating
properties, these capabilities are limited (see [1]).

Your repository component should offer means for querying or updating
the configurations that can be modified. When adding configurations to
the combined configuration you can specify names under which these child
configurations can be accessed; you can use this mechanism to obtain
references to specific child configurations that can then be updated.
When a child configuration is manipulated, the combined configuration is
automatically updated accordingly.

Would this work for you?

Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedconfiguration.html#Dealing_with_changes

> 
> Any hint ?
> 
> Thank you.
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Prefix for combined configuration

2016-04-09 Thread Oliver Heger
Hi Mansour,

Am 09.04.2016 um 06:07 schrieb Mansour Al Akeel:
> Hello,
> 
> I am trying to load multiple sources into a CombinedConfiguration
> object. However, I need to access each property using a prefix.
> For example, a property that resides in "global.xml" needs to be
> accessed with a unique prefix:
> 
> glob:this.is.a.global.property.
> 
> And a property that is loaded from "case.properties", needs to be
> accessed with the prefix:
> 
> case:another.case.specific.property
> 
> I can extend CombinedConfiguration and override the getters, or create
> a map. But if it's possible out of the box, it will save me sometime.
> So here's my sample code:
> 
> Parameters params = new Parameters();
> 
> URL url =
> ConfigurationManager.class.getClassLoader().getResource("META-INF/global.xml");
> URL url2 =
> ConfigurationManager.class.getClassLoader().getResource("META-INF/case.properties");
> 
> FileBasedConfigurationBuilder globBuilder =
> new FileBasedConfigurationBuilder(XMLConfiguration.class);
> globBuilder = globBuilder.configure(params.xml().setURL(url));
> 
> FileBasedConfigurationBuilder
> testBuilder = new
> FileBasedConfigurationBuilder(PropertiesConfiguration.class);
> testBuilder.configure(params.properties().setURL(url2));
> 
> CombinedConfiguration cc = new CombinedConfiguration();
> 
> // cc.setExpressionEngine(new XPathExpressionEngine());
> 
> cc.addConfiguration(globBuilder.getConfiguration(), null, "global:");
> cc.addConfiguration(testBuilder.getConfiguration(), null, "case:");
> 
> config = ConfigurationUtils.unmodifiableConfiguration(cc);
> 
> 
> This is working great so far, as I can do:
> 
> global:.this.is.a.global
> 
> Please note the dot in the dotted notation, between the prefix and the
> property name. It will be nice if I there is an easy way to remove it,
> so that I can do "global:this.is.a.global.property".

When a prefix is provided when adding a configuration to a
CombinedConfiguration, internal node structures are created that
correspond to this prefix. Resolving of such keys therefore requires a
dot (or separator) behind the prefix because the nodes with
configuration data are actually child nodes of the prefix node. This is
how it works internally.

Maybe the following trick could be an option: You could create your own
ExpressionEngine implementation that delegates to another
ExpressionEngine instance. In the implementation of the query() method
you modify the passed in key by replacing the first ":" by ":." and then
invoke the wrapped engine. I guess this should achieve what you want and
is pretty straight-forward.

Oliver

> 
> Any advice ?
> 
> 
> Thank you.
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration]

2016-04-02 Thread Oliver Heger
Hi Rainer,

On 01.04.2016 23:52, Rainer Hirschmiller wrote:
> Hi.
> 
> I'm trying configurations2 and PropertiesConfiguration. I have created a
> helper class doing some error handling and configuration for
> ProperiesConfiguration. Especially I load properties from different
> property files. I want to do this to define basic configurations in one
> file and be able to override these configurations in a second file which
> will be loaded later.
> 
> Getting the property of such a double defined key which public  T
> get(final Class cls, final String key) I got the first defined value.
> OK, I've overriden the method to get the last defined value.
> 
> But I want to know why the behaviour is at it is. Is there a special
> reason? I think returning the last defined value would be preferred by
> other users allthough. What's do other users think about this behaviour?

when multiple configuration files are loaded into a
PropertiesConfiguration a union of the configuration settings is
created. In your case, you get a property with multiple values, and
querying this property with a get method that returns only a single
value selects the first value per default. With getList() you could
query all values of this property.

IIUC, what you want to achieve is an override semantics. The preferred
way to do this with Commons Configuration is using a
CombinedConfigurationBuilder. This builder reads a definition file that
references multiple configuration sources and constructs a combined
configuration out of it. You can control how this combination is done,
e.g. with union or override semantics.

Please have a look at the user's guide:
http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedbuilder.html

There is a section "Overriding properties" that should describe your use
case.

Oliver

> 
> Regards
> Rainer
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] use commons configuration 2 as PropertySource in Spring

2016-03-31 Thread Oliver Heger
Hi Dennis,

Am 31.03.2016 um 14:27 schrieb Dennis Kieselhorst:
> Hi,
> 
> great to see that Commons Configuration 2.0 is out.
> 
> There is one question that appeared during the migration in one of my
> projects. With Commons Configuration 1.0 a Spring modules factory bean
> (org.springmodules.commons.configuration.CommonsConfigurationFactoryBean) was
> used to directly use Commons Configuration with Spring's
> PropertyPlaceholderConfigurer. As this is no longer maintained, the
> question is how to do this with Commons Configuration 2.0.
> 
> Of course it should be possible to copy the existing Spring modules
> source code to the project and migrate it to 2.0. Is there some better
> way to do this? I know Spring offers YAML, but it should be still
> Commons Configuration (the existing XML configuration files should not
> be affected).

I never used CommonsConfigurationFactoryBean myself. It is unfortunate
that the Spring Modules project is no longer active; the best solution
would probably be to update the factory bean on Spring side.

I am not sure how to proceed in this question. I am reluctant to adding
a corresponding integration to Commons Configuration itself because this
would require adding all those Spring dependencies and seems to be a bit
out of scope.

Oliver

> 
> Cheers
> Dennis
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.0 Released

2016-03-25 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.0.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

After a series of alpha and beta releases, this is the first final
release for Apache Commons Configuration 2.0.

Version 2 is a major redesign of the Configuration API. It breaks
compatibility in many areas and, therefore, is not a drop-in replacement
for Commons Configuration 1.x. Changes on client code are required. If
you want to upgrade from Commons Configuration 1.x to the new version,
make sure to consult the upgrade guide at
  http://commons.apache.org/configuration/userguide/upgradeto2_0.html
which describes the breaking changes.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

The user's guide has been updated to describe all the new features of
Configuration 2.0. It can be found at
  http://commons.apache.org/configuration/userguide/user_guide.html


Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

Please verify signatures using the KEYS file available at the above
location when downloading the release.

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] 1.10 regression / backwards-incompatible change in MapConfiguration.convertPropertiesToMap ?

2016-01-14 Thread Oliver Heger


Am 13.01.2016 um 23:23 schrieb Gary Gregory:
> On Wed, Jan 13, 2016 at 11:43 AM, Norbert Kiesel 
> wrote:
> 
>>> Hi Norbert,
>>>
>>> due to lack of time, I recently only focused on Configuration 2.0 and
>>> intended to let the 1.x series slowly die. Therefore, my priority is to
>>> get 2.0 ready and push the release out. If I understand correctly, the
>>> implementation in 2.0 satisfies your needs, except that some generic
>>> types still have to be adapted (passing a Map to the
>>> constructor rather than a Map). Is this correct?
>>
>> Yes, 2.0 satifies our need (even the current version, though I agree with
>> your
>> suggested type change).
>>
>>>
>>> Patches for a 1.11 fix release are of course welcome, but I cannot
>>> promise that I will be able to actually do a 1.11 release in the near
>>> future. If somebody else steps up and volunteers to do this, this would
>>> of course be another story.
>>
>> Understood.  Really only trying to help here, not to produce more work for
>> you
>> or the community.  We will simply stick with 1.9 until 2.0 is out.
>>
>>>
>>> ...
>>>

 The way out for a potential 1.11 would be to override more of the the
 AbstractMap API to make that a mutable map backed by the Properties
>> object.  Do
 you want me to provide a patch along these lines?
>>>
>>> This approach would probably work, but it seems like unnecessary
>>> complexity. Accessing the passed in Properties object directly - as done
>>> in 2.0 - is more straight-forward, isn't it?
>>
>> This would break backwards compatibility: 1.x promises to actively weed out
>> entries with non-string keys from the passed Properties object. So anyone
>> depending on this would be in for a surprise.  2.0 instead warns callers
>> that they have to
>> ensure that they don't pass such entries.  This makes life simpler for the
>> implementation
>> and is IMHO very good for an API-breaking 2.x but not for 1.x.
>>
>> I don't want to waste anyone's time here, so unless you tell me that you
>> want to see the
>> revised patch or otherwise actively engage, I will shut up on this topic.
>> Was a pleasure to
>> talk to you and thanks for your community work!
>>
> 
> Thank you for your understanding and help. We are all volunteers short on
> time.
> 
> You might want to submit a 1.x patch in case an RM decides to push out a
> release. That would grease the wheels a bit. Just in case...
> 
> Gary

Full agreement to what Gary said. Many thanks for your support and
constructive feedback, Norbert!

Oliver

> 
>>
>> 
>>
>> Confidentiality Notice:This email and any files transmitted with it are
>> confidential and intended solely for the use of the individual or entity to
>> whom they are addressed. This message contains confidential information and
>> is intended only for the individual named. If you are not the named
>> addressee you should not disseminate, distribute or copy this e-mail.
>> Please notify the sender immediately by e-mail if you have received this
>> e-mail by mistake and delete this e-mail from your system. If you are not
>> the intended recipient you are notified that disclosing, copying,
>> distributing or taking any action in reliance on the contents of this
>> information is strictly prohibited
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
> 
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] 1.10 regression / backwards-incompatible change in MapConfiguration.convertPropertiesToMap ?

2016-01-12 Thread Oliver Heger
Hi Norbert,

Am 11.01.2016 um 23:37 schrieb Norbert Kiesel:
> Attached is a patch with an extended unit test (which the patched code 
> passes, but the current 1.10 fails).
> 
> Just using the 2.0 code does not work, because
>  - the 1.10 API uses Map and not Map
>  - the 1.10 MapConfiguration(Properties props) constructor mandates that the 
> implementation has to ignore property keys which are not strings.
> 

The goal should be that the 2.0 code satisfies all requirements. If this
is not the case, we should adapt it. It seems that there have been
slight API changes in the constructors of MapConfiguration in the 1.10
release which have not been merged back to the main branch. This should
be aligned.

> So instead the patch simply creates a new HashMap from the Properties entries 
> with String keys.
> 
> However, this makes TestSystemConfigurationRegression fail now.  I understand 
> why, but I don't understand why this is a valid test case.
> 
> TestSystemConfigurationRegression assumes that a SystemConfiguration 
> instances changes when a System property is added.  The old code did that, 
> and the patched code does not.  However, MapConfiguration(Properties props) 
> javadoc for 1.10 clearly states: "The resulting configuration is not 
> connected to the Properties object".  So why is this a valid test case?

There have been multiple iterations with SystemConfiguration regarding
life-access to the underlying system properties. I think, most
developers expect that this configuration is just a thin wrapper over
System.getProperties(). Hence, updates of system properties should be
immediately reflected by the configuration. The fact that
SystemConfiguration extends MapConfiguration is merely an implementation
detail; this does not mean that it only represents a snapshot of system
properties at creation time.

Oliver

> 
> 
> Confidentiality Notice:This email and any files transmitted with it are 
> confidential and intended solely for the use of the individual or entity to 
> whom they are addressed. This message contains confidential information and 
> is intended only for the individual named. If you are not the named addressee 
> you should not disseminate, distribute or copy this e-mail. Please notify the 
> sender immediately by e-mail if you have received this e-mail by mistake and 
> delete this e-mail from your system. If you are not the intended recipient 
> you are notified that disclosing, copying, distributing or taking any action 
> in reliance on the contents of this information is strictly prohibited
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] 1.10 regression / backwards-incompatible change in MapConfiguration.convertPropertiesToMap ?

2016-01-10 Thread Oliver Heger
Hi,

Am 07.01.2016 um 20:33 schrieb Norbert Kiesel:
> Hi,
> 
> 
> we just tried to upgrade from commons-configuration-1.9 to 
> commons-configuration-1.10 and hit a blocking problem.  It manifests itself 
> as:
> 
> java.lang.UnsupportedOperationException
> at java.util.AbstractMap.put(AbstractMap.java:209)
> at 
> org.apache.commons.configuration.MapConfiguration.addPropertyDirect(MapConfiguration.java:186)
> at 
> org.apache.commons.configuration.AbstractConfiguration.addPropertyValues(AbstractConfiguration.java:423)
> at 
> org.apache.commons.configuration.AbstractConfiguration.addProperty(AbstractConfiguration.java:393)
> at 
> org.apache.commons.configuration.AbstractConfiguration.setProperty(AbstractConfiguration.java:486)
> 
> 
> 
> Looks like this happens because the map was created using the 
> `MapConfiguration(Properties props)` constructor.  In 1.9, this creates a 
> HashMap and fills it with the properties.  In 1.10, this now uses an 
> AbstractMap that only overrides `entrySet` which makes this a read-only map.
> 
> 
> Our code then tries to add more properties, which produces the above 
> exception.
> 
> 
> Are we doing something wrong here or is this really a regression in 1.10?
> 

This seems to be a regression in 1.10, unfortunately. According to SVN
history, the code in MapConfiguration has been patched to fix
CONFIGURATION-556 [1]. The fact that the MapConfiguration can no longer
be updated is probably an undesired side effect.

I assume that this will work again with version 2.0. In this version,
MapConfiguration just stores the Properties object passed to the
constructor. So updates are not a problem.

Oliver

[1] https://issues.apache.org/jira/browse/CONFIGURATION-556

> 
> 
> 
> 
> 
> ---
> 
> 
> Norbert Kiesel
> Systems Architect | Engineering
> MetricStream
> 2600 E. Bayshore Road | Palo Alto, CA - 94303
> +1-650-620-2954 | nkie...@metricstream.com | www.metricstream.com
> 
> Confidentiality Notice:This email and any files transmitted with it are 
> confidential and intended solely for the use of the individual or entity to 
> whom they are addressed. This message contains confidential information and 
> is intended only for the individual named. If you are not the named addressee 
> you should not disseminate, distribute or copy this e-mail. Please notify the 
> sender immediately by e-mail if you have received this e-mail by mistake and 
> delete this e-mail from your system. If you are not the intended recipient 
> you are notified that disclosing, copying, distributing or taking any action 
> in reliance on the contents of this information is strictly prohibited
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.0-beta2 Released

2015-12-06 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.0-beta2.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

This is another beta release incorporating some minor API changes in
reaction to community feedback. Hopefully the API is stabilizing towards
the final 2.0 release.

Version 2 is a major redesign of the Configuration API.
It breaks compatibility in many areas and, therefore, is not a drop-in
replacement for Commons Configuration 1.x. The main purpose of this
series of alpha and beta releases is to gather feedback from the
community about the reworked API. IT IS NOT YET PRODUCTION READY. There
may still be some changes on the public API.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

There is also an upgrade guide available for users of version 1.x at
  http://commons.apache.org/configuration/userguide/upgradeto2_0.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release. (Note: Because this
is a beta version, we decided that it will not be distributed to Maven
central.)

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Fwd: Parse XML configuration file with namespaces

2015-11-25 Thread Oliver Heger
Hi Maurizio,

you are probably affected by this bug:

https://issues.apache.org/jira/browse/CONFIGURATION-573

It has been fixed for the upcoming 2.0 release, but is not available for
Configuration 1.10. I fear, you will have to use the default expression
engine for the time being :-(

Oliver

Am 25.11.2015 um 09:37 schrieb Maurizio Lattuada:
> Hi @all,
> 
> 
> @Siegfried: all my XSD files are stored locally. In fact, when I call
> the "load()" method (setSchemaValidation is true), the XML is loaded
> correctly. By the way, I introduced on purpose some errors in the XML
> file and it was not correctly loaded, meaning that the validation is
> really active and working (so, XSD files are correctly found).
> 
> @Oliver: thanks for the hint, but I think there is a strange behavior
> in my opinion.
> 
> Iterator it = xmlPersonConfiguration.getKeys();
> while (it.hasNext()) {
> LOGGER.info(it.next());
> }
> final String string = namespace + Tags.PERSON; // namespace is a
> parameter equals to "p:"
> xmlPerson = xmlPersonConfiguration.configurationsAt(string);
> LOGGER.info("--> Found " + xmlPerson.size() + " persons (key: " +
> string + ")");
> 
> This lead to have:
> 2015-11-25 09:08:10,320 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : p:person/p:title
> 2015-11-25 09:08:10,324 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : p:person/p:firstName
> 2015-11-25 09:08:10,326 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : p:person/p:lastName
> ...all the tags here are correctly logged...
> 2015-11-25 09:08:10,346 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : @xmlns:ath
> 2015-11-25 09:08:10,346 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : @xmlns:com
> 2015-11-25 09:08:10,346 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : @xmlns:p
> 2015-11-25 09:08:10,347 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : @xmlns:xsi
> 2015-11-25 09:08:10,347 [c.v.t.b.r.ConfigReader:402  ] INFO  -
> parsePerson : @xsi:schemaLocation
> 2015-11-25 09:08:10,720 [c.v.t.b.r.ConfigReader:406  ] INFO  -
> parsePerson :  --> Found 0 persons (key: p:person)
> 
> Question: since my xml file has this structure (I omit the namespace
> declaration for ease of reading):
> 
>   
> ...
> ...
>   
>   
> ...
> ...
>   
> 
> 
> Why "p:person" is not in the keys, but only the sub-tags of p:person?
> When I had my xml with the XSD, but without namespaces, looking for
> "person" worked fine, so I was able to iterate on the 2 persons
> available in the XML example above.
> 
> By the way, I also tried to look for "p:person/p:title", that is a key
> found by calling the "getKeys()" method:
> xmlPerson = xmlPersonConfiguration.configurationsAt("p:person/p:title");
> LOGGER.info("--> Found " + xmlPerson.size() + " persons");
> 
> but the xmlPerson.size is always equal to 0.
> FYI xmlPersonConfiguration is created and initialized as:
> 
> XMLConfiguration xmlPersonConfiguration = new XMLConfiguration();
> xmlPersonConfiguration.setExpressionEngine(new
> XPathExpressionEngine());
> xmlPersonConfiguration.setSchemaValidation(true);
> xmlPersonConfiguration.setFileName("...");
> xmlPersonConfiguration.load();
> 
> If I don't call the "setExpressionEngine" method and I search for tags
> like "p:person.p:title" or "p:person", all these entries are correctly
> found and I can iterate over them.
> 
> Any other suggestions?
> 
> 
> thanks in advance for the feedback.
> 
> 2015-11-24 21:26 GMT+01:00 Oliver Heger <oliver.he...@oliver-heger.de>:
>> Hi Maurizio,
>>
>> in order to debug your problem, you can call the configuration's
>> getKeys() method. From the iterator returned you should see the
>> available keys. These keys can then also be used for querying properties.
>>
>> HTH
>> Oliver
>>
>> Am 24.11.2015 um 13:54 schrieb Maurizio Lattuada:
>>> Hi guys,
>>>
>>> I'm dealing with a strange problem while parsing an XML file (with
>>> namespaces) using commons configuration 1.10.
>>> First of all, let me say that when I call the "load()" method on the
>>> following XML file (validation is active), it is loaded flawless.
>>>
>>> This is an extract of the xml to be parsed:
>>> 
>>> 
>>> >> action="create"
>>> xmlns:ath="tdm:configuration:authentication"
>>&

Re: Fwd: Parse XML configuration file with namespaces

2015-11-24 Thread Oliver Heger
Hi Maurizio,

in order to debug your problem, you can call the configuration's
getKeys() method. From the iterator returned you should see the
available keys. These keys can then also be used for querying properties.

HTH
Oliver

Am 24.11.2015 um 13:54 schrieb Maurizio Lattuada:
> Hi guys,
> 
> I'm dealing with a strange problem while parsing an XML file (with
> namespaces) using commons configuration 1.10.
> First of all, let me say that when I call the "load()" method on the
> following XML file (validation is active), it is loaded flawless.
> 
> This is an extract of the xml to be parsed:
> 
> 
>  action="create"
> xmlns:ath="tdm:configuration:authentication"
> xmlns:com="tdm:configuration:common"
> xmlns:p="tdm:configuration:entities"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> xsi:schemaLocation="tdm:configuration:entities ../xsd/model/persons.xsd ">
> 
> Dr.
> ...
> 
> 
> Mr.
> ...
> 
> 
> 
> This is an extract of the persons.xsd, as you can see there are a
> couple of imports
> 
>  xmlns:common="tdm:configuration:common"
> xmlns:authentication="tdm:configuration:authentication"
> targetNamespace="tdm:configuration:entities"
> xmlns:xs="http://www.w3.org/2001/XMLSchema; 
> elementFormDefault="qualified">
>  namespace="tdm:configuration:common" />
>  namespace="tdm:configuration:authentication" />
> 
> 
> 
> 
> And finally an extract of the code to setup the parse and to read the 
> document:
> XMLConfiguration xmlPersonConfiguration = new XMLConfiguration();
> xmlPersonConfiguration.setDelimiterParsingDisabled(true); // needed
> because I've attribute with multiple values like "a,b,c"
> xmlPersonConfiguration.setExpressionEngine(new XPathExpressionEngine());
> xmlPersonConfiguration.setSchemaValidation(true);
> xmlPersonConfiguration.setFileName("persons.xml");
> xmlPersonConfiguration.load();
> List xmlPersons;
> xmlPersons = xmlPersonConfiguration.configurationsAt("person");
> 
> Shortly, either I try to search for (last statement):
>  * person
>  * p:person
>  * //person
>  * //p:person
>  * /p:persons/p:person
>  *...
> 
> No elements are found.
> According to the commons configuration documentation, "The XML Parser
> will then use the schema defined in the XML document to validate it.
> Enabling schema validation will also enable the parser's namespace
> support.".
> Please note: before I had such xml and xsd files without namespaces
> and everything worked fine.
> 
> I'm pretty sure I'm doing something wrong, but I can't figure what.
> Any idea about this behavior?
> 
> Thanks for your kind feedback
> 
> --
>  Maurizio Lattuada
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] How to read an INI Configuration with brackets as list separator

2015-08-26 Thread Oliver Heger


Am 25.08.2015 um 17:33 schrieb Thomas Vandahl:
 On 25.08.15 07:55, Patrick Brunmayr wrote:
 Hello

 How can i read a configuration like that ?

 [RESPONSE]
 code = 200
 description = Command completed successfully
 queuetime = 0
 runtime = 0.006
 property[count][0] = 164
 property[domain][0] = xxx
 property[domain][1] = xxx
 property[domain][2] = xxx

 
 Hi Patrick,
 
 list separators are for values, not keys. See the JavaDoc for
 HierarchicalINIConfiguration for a way to handle files like this. You
 may want to check out the section
 http://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_xml.html#Accessing_structured_properties
 of the users guide for possibilities to access your data. Using the
 XPathExpressionEngine might cover your case but that's just a wild guess.
 
 HTH
 Bye, Thomas.

As Thomas said, there is no mechanism to group keys following a specific
pattern to lists or something like that.

As long as the keys do not contain the configurable separator character,
they are processed in the usual way and can be queried verbatim. If you
want to fetch for instance all values assigned to a property like
'property[domain]', you have to construct the keys yourself and do the
necessary looping. Maybe you can use the getKeys() method which expects
a prefix to select a specific subset of keys.

Oliver

 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Mutable BasicDynaBean Map

2015-06-22 Thread Oliver Heger


Am 22.06.2015 um 21:56 schrieb Ercan Canlıer:
 Hello,
 As i mentioned at the mail subject, i am having problem with not mutable
 map inside BasicDynaBean.
 As far as i know, it is the default behaviour of this map.
 What i would like to do is, simply retrieve the resultset from db which
 will create a list including DynaBeans.
 For viewing the database table, everything works fine, the problem occurs
 when i try to edit it and i get the following exception:
 
 Caused by: javax.el.PropertyNotWritableException
 at javax.el.MapELResolver.setValue(MapELResolver.java:267)
 at
 com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
 at
 com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
 at com.sun.el.parser.AstValue.setValue(AstValue.java:201)
 at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291)
 at
 com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)
 ... 50 more

This stack trace does not contain a reference to Commons BeanUtils.
Also, the exception thrown is from the Java expression language (EL),
not from BeanUtils. It seems to me that there is already a problem in
your path expression before the DynaBean is actually hit.

I don't know EL well enough, but could it be the case that it simply
cannot handle dyna beans?

Oliver

 
 I assume, this is because of the map inside dyna bean is not mutable.
 I think one option is to change the default behaviour of the map by editing
 the source code of BeanUtils library.
 On the other hand, i think the implementors of this library must have
 thought this functionality somehow...
 Below is the code snippet that i use for retrieving the result set as
 DynaBeans.
 
 
 String query = SELECT * FROM test.a;
 
 Statement stmt = (Statement) con.createStatement();
 ResultSet rs = stmt.executeQuery(query);
 RowSetDynaClass rsdc = new RowSetDynaClass(rs);
 
 rs.close();
 stmt.close();
 dynaObjectList= rsdc.getRows();
 
 I tried to use LazyDynaMap as well, editing the table worked fine but the
 Map didnt allow me to put multiple data since the key is not unique for
 other datasets.
 Because the key is the property name.
 
 I would be really appreciated if you suggest me hints.
 Thanks in advance.
 I am really looking forward to see the answers if possible.
 Best regards.
 Ercan CANLIER
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Apache Commons Configuration Version 2

2015-05-06 Thread Oliver Heger
Hi Ron,

Am 06.05.2015 um 03:38 schrieb DiFrango, Ronald (CONT):
 Oliver,
 
 I guess I could build it from source and store it in our local Nexus until a 
 release version is built.
 

this is of course possible. I do not expect major or breaking changes
until the final release.

Thanks for your feedback, this is indeed motivating :-)

Oliver

 Ron DiFrango
 
 -Original Message-
 From: DiFrango, Ronald (CONT) [mailto:ronald.difra...@capitalone.com] 
 Sent: Tuesday, May 05, 2015 4:23 PM
 To: Commons Users List
 Subject: RE: [configuration] Apache Commons Configuration Version 2
 
 Oliver,
 
 I figured it would be something like that and that's understandable as is the 
 time-table.  We definitely like the feature set of 2.x as it supports many of 
 the uses cases more naturally than 1.x so would like to move forward with it.
 
 But I can't unless it's in maven central.
 
 Thanks,
 
 Ron
 
 
 -Original Message-
 From: Oliver Heger [mailto:oliver.he...@oliver-heger.de] 
 Sent: Tuesday, May 05, 2015 4:20 PM
 To: Commons Users List
 Subject: Re: [configuration] Apache Commons Configuration Version 2
 
 Hi Ron,
 
 Am 05.05.2015 um 22:09 schrieb DiFrango, Ronald (CONT):
 All,

 Is Apache commons configuration in maven central or some other repo?  I'm 
 using Gradle and pointing to an internal Nexus repo that is a proxy for 
 Maven central and I can't resolve it as follows:

 compile group: 'org.apache.commons', name: 'commons-configuration2', 
 version: '2.0-alpha2'


 
 because it is only an alpha release, this version has not been deployed to a 
 public Maven repository. We did this by intension to avoid potential jar hell 
 if there are still binary incompatible changes before the final release.
 
 I am working to get the final version 2.0 out, but unfortunately my time is 
 currently pretty limited. So I cannot predict a release schedule.
 
 Oliver
 
 Thanks,

 Ron

 

 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith 
 is intended only for use by the individual or entity to which it is 
 addressed.  If the reader of this message is not the intended recipient, you 
 are hereby notified that any review, retransmission, dissemination, 
 distribution, copying or other use of, or taking of any action in reliance 
 upon this information is strictly prohibited. If you have received this 
 communication in error, please contact the sender and delete the material 
 from your computer.

 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 
 
 
 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith is 
 intended only for use by the individual or entity to which it is addressed.  
 If the reader of this message is not the intended recipient, you are hereby 
 notified that any review, retransmission, dissemination, distribution, 
 copying or other use of, or taking of any action in reliance upon this 
 information is strictly prohibited. If you have received this communication 
 in error, please contact the sender and delete the material from your 
 computer.
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 
 
 
 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith is 
 intended only for use by the individual or entity to which it is addressed.  
 If the reader of this message is not the intended recipient, you are hereby 
 notified that any review, retransmission, dissemination, distribution, 
 copying or other use of, or taking of any action in reliance upon this 
 information is strictly prohibited. If you have received this communication 
 in error, please contact the sender and delete the material from your 
 computer.
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Apache Commons Configuration Version 2

2015-05-05 Thread Oliver Heger
Hi Ron,

Am 05.05.2015 um 22:09 schrieb DiFrango, Ronald (CONT):
 All,
 
 Is Apache commons configuration in maven central or some other repo?  I'm 
 using Gradle and pointing to an internal Nexus repo that is a proxy for Maven 
 central and I can't resolve it as follows:
 
 compile group: 'org.apache.commons', name: 'commons-configuration2', version: 
 '2.0-alpha2'
 
 

because it is only an alpha release, this version has not been deployed
to a public Maven repository. We did this by intension to avoid
potential jar hell if there are still binary incompatible changes before
the final release.

I am working to get the final version 2.0 out, but unfortunately my time
is currently pretty limited. So I cannot predict a release schedule.

Oliver

 Thanks,
 
 Ron
 
 
 
 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith is 
 intended only for use by the individual or entity to which it is addressed.  
 If the reader of this message is not the intended recipient, you are hereby 
 notified that any review, retransmission, dissemination, distribution, 
 copying or other use of, or taking of any action in reliance upon this 
 information is strictly prohibited. If you have received this communication 
 in error, please contact the sender and delete the material from your 
 computer.
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration]

2015-03-02 Thread Oliver Heger


Am 02.03.2015 um 10:53 schrieb Velladurai Pandian, Ashok Kumar:
 I have a hierarchy of property files which are available in various folders 
 in my file system. The file names are same but the folders are named based on 
 the base group and specific group id and.
 
 I have a requirement of creating group based configurations of all the 
 available property files. Based on the user login I need load their 
 respective group and if not available at that level it would go to the base 
 group and get the key.
 
 I am trying use the 
 MultiFileConfigurationBuilderhttp://commons.apache.org/proper/commons-configuration/xref/org/apache/commons/configuration2/builder/combined/MultiFileConfigurationBuilder.html
  and trying to set the pattern to combine the configurations. To the pattern 
 I would set the group id and get the configuration and merge with that of the 
 base group.
 
 But the pattern does not seem to be working. Is it possible to load and merge 
 the configurations just only using the config.xml files?
 
 Please let me know if you have a better approach.
 
 Parameters params = new Parameters();
MultiFileBuilderParameters multiParam = 
 params.multiFile().setFilePattern(${GROUP_ID}/ 
 app_settings.properties).setManagedBuilderParameters(params.fileBased().setBasePath(C:/a_container/MyApp/));
MultiFileConfigurationBuilderPropertiesConfiguration builder = 
 new MultiFileConfigurationBuilder(
  PropertiesConfiguration.class).configure(multiParam);
  MapString, Object params1 = new HashedMapString, Object();
params1.put(GROUP_ID, 987987);
builder.setParameters(params1);
Configuration conf = builder.getConfiguration();
sopAllKeys((FileBasedConfiguration) conf);

The problem is that the variable in the file pattern cannot access
parameters passed to the builder. It is interpreted by the typical
interpolation mechanisms used by configuration objects (refer to
http://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#Variable_Interpolation).

Maybe you can solve your problem with Java system properties. Set the
name of the directory as a specific system property and reference the
same property in your expression with the sys prefix (e.g.
${sys:mySystemProperty}). There is an example which embeds a multi file
configuration into a DynamicCombinedConfiguration also using system
variables to load the correct configuration files:

http://commons.apache.org/proper/commons-configuration/userguide/howto_multitenant.html#Sample_Configuration

HTH
Oliver

 
 Regards,
 Ashok
 
 _
 The information contained in this message is proprietary and/or confidential. 
 If you are not the intended recipient, please: (i) delete the message and all 
 copies; (ii) do not disclose, distribute or use the message in any manner; 
 and (iii) notify the sender immediately. In addition, please be aware that 
 any message addressed to our domain is subject to archiving and review by 
 persons other than the intended recipient. Thank you.
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Adding CData to xml property

2015-01-06 Thread Oliver Heger



On 06.01.2015 17:55, jeevi tesh wrote:

Hi,

Need to add CDATA into XML Property element, but special character are
getting added. Here is my code. Please give your thoughts on the same.

Here is the code.

String cDataTagStart=\\![CDATA[;

String cDataTagEnd=]]\\;

credentialsURL =cDataTagStart+credentialsURL+cDataTagEnd;

xmlContentOfMetaData = CredentialProvider.*getInstance*();

xmlContentOfMetaData.addProperty(Resource(-1).ResourceName, resourceName);

xmlContentOfMetaData.addProperty(Resource.ResourceURL, credentialsURL);



But Special characters are getting added

ResourceNameTESTRESOURCENAME/ResourceName

ResourceURL\lt;![CDATA[TESTCredentialsURLS2]]\gt;/ResourceURL



XMLConfiguration ensures that for newly added or updated properties 
valid XML is generated. Therefore, special characters are encoded 
automatically. This frees applications from the burden to do the 
encoding manually. However, there is less control of the XML generated.


Currently, XMLConfiguration does not supported the generation of CDATA 
sections. You may want to add a feature request in our bug tracking 
system [1].


Oliver

[1] 
http://commons.apache.org/proper/commons-configuration/issue-tracking.html




Thanks

jeevitesh



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Adding New property

2015-01-02 Thread Oliver Heger

Hi,

note that this is a shared mailing list, so it is convention to prefix 
the subject with the name of the component the question relates to.


Please have a look at the user's guide at
http://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_xml.html#Adding_new_properties

There is an example how properties can be added to a complex XML structure.

HTH
Oliver

On 02.01.2015 19:50, jeevi tesh wrote:

Hi,
I need to add a new property facing lots of issue suggestion required.
Here is my XML format
?xml version=1.0 encoding=UTF-8?
Resources
  Resource
   ResourceNameblackwoods/ResourceName
   ResourceURL![CDATA[WWW.blackwoods.com]]/ResourceURL
  /Resource


  Resource
   ResourceNameordermax/ResourceName
   ResourceURL![CDATA[http://www.ordermax.com]]/ResourceURL
  /Resource
/Resources

I need to add new property like
  Resource
   ResourceNamedell/ResourceName
   ResourceURL![CDATA[http://www.dell.com]]/ResourceURL
  /Resource
i Have tried like
1. addProperty(Resource.ResourceName) - issue with this approach is it
add within last element like
  Resource
   ResourceNameordermax/ResourceName
   ResourceURL![CDATA[http://www.ordermax.com]]/ResourceURL
ResourceNamedell/ResourceName
   ResourceURL![CDATA[http://www.dell.com]]/ResourceURL
  /Resource

2. used setProperty(Resource.ResourceName) - deletes all the existing
property. so tried to read all items in xml and then use setproperty when i
use save it saves only last elements.
String temp2=+dell+\n+\nResourceURL+www.dell.com+\n/ResourceURL;
3. used addProperty(Resourcetemp2);
But this approach is adding special charters like below
Resourcelt;ResourceNamegt;dellt;/ResourceNamegt;lt;ResourceURLgt;
www.dell.comlt;/ResourceURLgt;/Resource
Please help me to resolve the same
Thanks



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.0-alpha2 Released

2014-12-20 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.0-alpha2.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

This is the second alpha release for version 2.0 of Commons
Configuration containing some more API fine-tuning.

Version 2 is a major redesign of the Configuration API.
It breaks compatibility in many areas and, therefore, is not a drop-in
replacement for Commons Configuration 1.x. The main purpose of this
series of alpha releases is to gather feedback from the community about
the reworked API. IT IS NOT YET PRODUCTION READY. There may still be
some changes on the public API.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

There is also an upgrade guide available for users of version 1.x at
  http://commons.apache.org/configuration/userguide/upgradeto2_0.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release. (Note: Because this
is an alpha version, we decided that it will not be distributed to Maven
central.)

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community
Have a happy holiday season!

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: BeanUtilsBean thread safe? Why wouldn't you make Fluent default?

2014-12-17 Thread Oliver Heger
Hi Clebert,

Am 15.12.2014 um 19:44 schrieb Clebert Suconic:
 Hello There..
 
 
 I'm going to use BeanUtils on ActiveMQ6 to solve properties on my URL parsing:
 
 
 I'm setting the BeanUtils instance static on a class.
 
 and I'm going to eventually use it for setting things on my factory:
 
 
 https://gist.github.com/clebertsuconic/be31b2789e7271db002b
 
 
 
 This is a link to my branch:
 https://github.com/clebertsuconic/activemq-6/blob/master-uri/activemq-commons/src/main/java/org/apache/activemq/utils/uri/URISchema.java
 
 However that's a transient branch, and that's why I added a gist here.
 
 
 
 So, is BeanUtilsBean thread safe? Do I need the synchronized around
 the class? I tried to read the code and I believed it wouldn't be safe
 to do it in multi-thread. (That's probably why you guys use a
 ThreadLocal).  The usage here will be very minimal (at my startup time
 only), so I didn't really mind having the synchronized...   but I
 wanted to double check for correctness..
 

your interpretation is correct, BeanUtilsBean is not thread-safe. It
uses an instance of PropertyUtilsBean under the hood, which is also not
thread-safe. This object maintains a map to cache the property
descriptors which have already been discovered during bean
introspection. The access to this map is not protected by any means. So
you have to take care for proper synchronization yourself.

Oliver

 
 
 also: Why won't you make the FluentIntrospector default on the default
 BeanUtils? it's not 2005 any more :)
 
 
 
 Anyways: I have worked with you guys before here... long time ago:
 https://issues.apache.org/jira/browse/BEANUTILS-291
 
 
 It was fun seeing something I did (my collaboration with Niall) almost
 10 years ago still in place at the current master :)
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [beanutils] Precision lost when converting BigDecimal

2014-09-30 Thread Oliver Heger
Hi,

Am 30.09.2014 um 09:26 schrieb Tommy Tynjä:
 Hi.
 
 I'm using commons-beanutils in my current project for bean copy
 operations. I have a use case where I would like to convert a domain
 specific object which extends BigDecimal to a regular
 java.math.BigDecimal. If my domain specific object contains decimals,
 precision is lost at time of conversion. A BigDecimal of e.g. value
 3200.11 will be converted to a BigDecimal with value 3200. This happens
 due to org.apache.commons.beanutils.converters.NumberConverter does a
 BigDecimal.valueOf(value.longValue()) at line 375 (current trunk). I've
 created a reproducing test case which demonstrates the behavior (please
 see the attached TestCase_ExtendingBigDecimal.patch file).
 
 Is this a bug or how am I expected to handle this use case?
 
 Adding the following code (please see attached NumberConverter.patch
 file) before executing else { return
 targetType.cast(BigDecimal.valueOf(value.longValue())); } in
 NumberConverter seems to fix this issue (and all project test cases pass):
 } else if (value instanceof BigDecimal) {
 return targetType.cast(value);
 }

this is probably a bug. The best way to go is opening a new ticket in
Jira [1] describing the problem. Please attach your unit test and your
proposed patch.

Thanks!
Oliver

 
 Best regards
 Tommy Tynjä
 
 
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 2.0-alpha1 Released

2014-09-25 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons Configuration 2.0-alpha1.

The Commons Configuration software library provides a generic
configuration interface which enables an application to read
configuration data from a variety of sources.

This is the first alpha release for version 2.0 of Commons
Configuration. Version 2 is a major redesign of the Configuration API.
It breaks compatibility in many areas and, therefore, is not a drop-in
replacement for Commons Configuration 1.x. The main purpose of this
alpha release is to gather feedback from the community about the
reworked API. IT IS NOT YET PRODUCTION READY. It is expected that there
will still be some changes on the public API.

A full list of all changes can be found in the release notes at
  http://www.apache.org/dist/commons/configuration/RELEASE-NOTES.txt

There is also an upgrade guide available for users of version 1.x at
  http://commons.apache.org/configuration/userguide/upgradeto2_0.html

Source and binary distributions are available for download from the
Apache Commons download site:

http://commons.apache.org/proper/commons-configuration/download_configuration.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release. (Note: Because this
is an alpha version, we decided that it will not be distributed to Maven
central.)

For complete information on Commons Configuration, including
instructions on how to submit bug reports, patches, or suggestions for
improvement, see the Apache Commons Configuration website:

http://commons.apache.org/proper/commons-configuration/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] JXPathException when setting the default expression engine

2014-09-12 Thread Oliver Heger

Hi Nick,

you are right, this is indeed a problem in 1.10. 
DefaultConfigurationBuilder extends XMLConfiguration; therefore, setting 
the default expression engine affects the way keys are resolved.


The preferred way to set the expression engine for the combined 
configuration produced by the builder is to declare the desired engine 
in the definition file that is loaded. There is an example in the user's 
guide [1] in the sub section The header section


In the upcoming version 2.0, this problem should no longer exist. Here 
different mechanisms are used for setting a default expression engine 
and for constructing a combined configuration. I hope that a first alpha 
release of Commons Configuration 2.0 will be available soon.


So, as the problem will be solved in the next version, it probably does 
not make sense to open a Jira ticket.


Oliver

[1] 
http://commons.apache.org/proper/commons-configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference


On 11.09.2014 21:37, Nick Watts wrote:

Hello, I've run into a problem that looks to me like a bug. I thought I'd
get some input on it first though.

Here are two JUnit test cases that both pass with Commons Config 1.10:

import static org.junit.Assert.*;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationBuilder;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.DefaultExpressionEngine;
import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
import org.apache.commons.jxpath.JXPathException;
import org.junit.Before;

public class Test {

 @Before
 public void before() {
 HierarchicalConfiguration.setDefaultExpressionEngine(new
DefaultExpressionEngine());
 }

 @org.junit.Test
 public void testSetExpressionEngineAfterLoad() throws
ConfigurationException {
 ConfigurationBuilder builder = new
DefaultConfigurationBuilder(configuration_builder.xml);
 ((XMLConfiguration)builder).setBasePath(src/test/resources/);
 Configuration config = builder.getConfiguration();
 HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine());
 assertEquals(mail.test.org, config.getString(mail/host));
 assertEquals(r...@test.org, config.getString(mail/from));
 assertEquals(otheru...@test.org, config.getString(mail/to));
 assertEquals(that...@test.org, config.getString(mail/cc));
 assertEquals(, config.getString(mail/bcc));
 }

 @org.junit.Test(expected=JXPathException.class)
 public void testSetExpressionEngineBeforeLoad() {
 try {
 HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine());
 ConfigurationBuilder builder = new
DefaultConfigurationBuilder(configuration_builder.xml);
 ((XMLConfiguration)builder).setBasePath(src/test/resources/);
 builder.getConfiguration();
 } catch (ConfigurationException e) {
 e.printStackTrace();
 }
 }
}


The configuration_builder.xml file:

?xml version=1.0 encoding=ISO-8859-1?
configuration
 override
 xml fileName=dev.config.xml config-name=env-config /
 xml fileName=config.xml config-name=default-config /
 /override
/configuration


the config.xml file:

?xml version=1.0 encoding=UTF-8?
config
 mail
 hostmail.test.org/host
 fromr...@test.org/from
 tonwa...@test.org/to
 cc/
 bcc/
 /mail
/config

the dev.config.xml file:

?xml version=1.0 encoding=UTF-8?
config
 mail
 tootheru...@test.org/to
 ccthat...@test.org/cc
 /mail
  /config



The possible bug is that the call to
HierarchicalConfiguration.setDefaultExpressionEngine(new
XPathExpressionEngine()) must come after the call to
builder.getConfiguration(). If it precedes builder.getConfiguration() then
you get this stack trace:

org.apache.commons.jxpath.JXPathException: Invalid XPath:
'[@systemProperties]'. Syntax error at the beginning of the expression
 at org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:60)
 at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression(JXPathContextReferenceImpl.java:218)
 at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(JXPathContextReferenceImpl.java:529)
 at
org.apache.commons.jxpath.JXPathContext.selectNodes(JXPathContext.java:654)
 at
org.apache.commons.configuration.tree.xpath.XPathExpressionEngine.query(XPathExpressionEngine.java:183)
 at
org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:958)
 at

Re: Commons Config: Variable Interpolation

2014-07-12 Thread Oliver Heger
Hi Ronald,

I have not used ExprLookup myself, so I am not sure whether I am a big
help here.

Your declaration of the lookup seems to be correct, otherwise an
exception would be thrown by DefaultConfigurationBuilder.

A difference between your code and the example in the user's guide is
that in the latter the expression lookup is directly used in the file
read by DefaultConfigurationBuilder and not in one of the included
configuration files. For version 2.0 (which is work in progress) this
should be supported, but I am not sure whether this also works in 1.x.

I would recommend to start with a simple example first. Test whether you
can access the lookup directly in this xml file, e.g. by setting the
file name of a configuration source as demonstrated in the example. By
this you can find out the results of variable substitutions and compare
them with your expectations. Only if this works as expected, try again
to use the lookup in an included configuration source.

HTH
Oliver

Am 11.07.2014 17:27, schrieb DiFrango, Ronald (CONT):
 Here's the full XML file:
 
 ?xml version=1.0 encoding=ISO-8859-1 ?
 
 configuration
   header
   result /
   lookups
   lookup config-prefix=expr
   
 config-class=org.apache.commons.configuration.interpol.ExprLookup
   variables
   variable name=net 
 value=Class:java.net.InetAddress /
   /variables
   /lookup
   /lookups
   /header
 
   system /
 
   properties fileName= example.properties listDelimiter=|
   reloadingStrategy refreshDelay=1
   
 config-class=org.apache.commons.configuration.reloading.FileChangedReloadingStrategy
  /
   /properties
 
 /configuration
 
 And the referenced properties file:
 
   mobile.rest.host=${expr:$[net.localHost.hostName]}
 
 
 Ron DiFrango
 
 
 
 -Original Message-
 From: Martin Gainty [mailto:mgai...@hotmail.com] 
 Sent: Friday, July 11, 2014 11:25 AM
 To: Commons Users List
 Subject: RE: Commons Config: Variable Interpolation
 
 
 
 From: ronald.difra...@capitalone.com
 To: user@commons.apache.org
 Date: Fri, 11 Jul 2014 11:02:45 -0400
 Subject: RE: Commons Config: Variable Interpolation

 Just to complete it, the code looks like:

 DefaultConfigurationBuilder factory = new 
 DefaultConfigurationBuilder(example.xml);
 Configuration config = factory.getConfiguration();
 
 MGno clue which properties are defined in example.xml so lets add a new 
 MGproperty called mobile.rest.host here 
 MGconfig.addProperty(mobile.rest.host, maps.google.com);
 
 System.out.println(Host Name =  + 
 config.getString(mobile.rest.host));
 MG?

 Ron DiFrango


 -Original Message-
 From: DiFrango, Ronald (CONT) [mailto:ronald.difra...@capitalone.com]
 Sent: Friday, July 11, 2014 10:49 AM
 To: user@commons.apache.org
 Subject: Commons Config: Variable Interpolation

 I'm attempting to perform Variable Interpolation as outlined here:

 http://commons.apache.org/proper/commons-configuration/userguide/howto
 _basicfeatures.html#Variable_Interpolation

 I'm using an XML file as the starter so I added the following blurb to the 
 beginning of the file:

 header
   result /
   lookups
  lookup config-prefix=expr

 config-class=org.apache.commons.configuration.interpol.ExprLookup
variables
   variable name=net 
 value=Class:java.net.InetAddress /
/variables
  /lookup
   /lookups
/header
 MG
 override
   xml mobileRestHost=String.lowercase(net.localHost.hostName)/xml
 /override
 MG?
 

 And then in my properties file that is loaded I did:

 mobile.rest.host=${expr:$[net.localHost.hostName]}

 But it did not work any thoughts on what I'm doing wrong?

 Thanks,

 Ron


 

 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith 
 is intended only for use by the individual or entity to which it is 
 addressed.  If the reader of this message is not the intended recipient, you 
 are hereby notified that any review, retransmission, dissemination, 
 distribution, copying or other use of, or taking of any action in reliance 
 upon this information is strictly prohibited. If you have received this 
 communication in error, please contact the sender and delete the material 
 from your computer.
 

 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith 
 is intended only for use by the individual or entity to 

Re: (beanutils) possible problem with beanutils being used by geoserver

2014-05-30 Thread Oliver Heger
Hello Joel,

Am 29.05.2014 19:12, schrieb Joel Harris:
 Hello,
 
 I'm trying to utilize the Geoserver v2.5 application on glassfish v4 with
 security manager enabled.
 when I navigate to certain areas in the web application I get a beanutils
 exception (toward the bottom of the stack trace below), trying to call a
 getter that apparently doesn't exist. I'm not sure why this is aggravated
 by enabling security manager, but perhaps it is bubbling up? This exception
 does not show up with security manager disabled.
 
 I have to keep security manager enabled, and can not allow all
 permissions to the application.
 Any help would be appreciated.

I am afraid I won't be a great help for your problem. It is completely
new to me that the set of properties detected by beanutils depends on
the existence of a security manager.

One thing I noticed from the stack trace: Could it be the case that the
class in question is a proxy? Maybe those are affected by a security
manager?

Oliver

 
 org.apache.wicket.WicketRuntimeException: Error attaching this container
 for rendering: [MarkupContainer [Component id = listContainer]]
 at
 org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1765)
 
 at org.apache.wicket.Component.onBeforeRender(Component.java:3946)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1071)
 at org.apache.wicket.Component.beforeRender(Component.java:1105)
 at
 org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1753)
 
 at org.apache.wicket.Component.onBeforeRender(Component.java:3946)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1071)
 at org.apache.wicket.Component.beforeRender(Component.java:1105)
 at
 org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1753)
 
 at org.apache.wicket.Component.onBeforeRender(Component.java:3946)
 at org.apache.wicket.Page.onBeforeRender(Page.java:1531)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1071)
 at org.apache.wicket.Component.beforeRender(Component.java:1105)
 at org.apache.wicket.Component.prepareForRender(Component.java:2292)
 at org.apache.wicket.Page.prepareForRender(Page.java:1521)
 at org.apache.wicket.Component.prepareForRender(Component.java:2329)
 at org.apache.wicket.Page.renderPage(Page.java:892)
 at
 org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:261)
 
 at
 org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)
 
 at
 org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258)
 
 at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
 at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
 at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
 at
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:484)
 at
 org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:138)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
 at
 org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
 
 at
 org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
 
 at
 org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 
 at
 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
 
 at
 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
 
 at
 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
 
 at
 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
 
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
 at sun.reflect.GeneratedMethodAccessor159.invoke(Unknown Source)
 at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 
 at java.lang.reflect.Method.invoke(Method.java:606) at
 org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:323)
 at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:321)
 at java.security.AccessController.doPrivileged(Native Method)
 at javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
 at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:356)
 at
 org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:214)
 
 at
 org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1676)
 at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
 
 at
 org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:90)
 
 at
 

Re: [configuration] Unexpected trimming when value contains escaped delimiter

2014-05-26 Thread Oliver Heger
Hello Cédric,

Am 26.05.2014 14:43, schrieb Cédric Couralet:
 Hello,
 
 When parsing a property string value containing a delimiter character,
 the resulting String is trimmed.
 See the following example :
 BaseConfiguration conf = new BaseConfiguration();
 conf.setProperty(test1, test\r\n);
 conf.setProperty(test2, test\\,test);
 conf.setProperty(test3, test\\,test\r\n);
 System.out.println(* + conf.getString(test1) + *);
 System.out.println(* + conf.getString(test2) + *);
 System.out.println(* + conf.getString(test3) + *);
 
 Expected :
 
 *test
 *
 *test,test*
 *test,test
 *
 
 Actual:
 
 *test
 *
 *test,test*
 *test,test*
 
 This is caused by the flatten method in PropertyConverter which calls
 the split(value,delimiter) which results in
 split(value,delimiter,true) causing the trimming.
 
 Is there a way to disable this trimming?
 I don't really know if this is expected behavior so I didn't open a
 bug report, should I?

Splitting at delimiter characters has always been a source for bugs and
inconsistencies. I think you have discovered one more, so feel free to
open a bug report in Jira.

Note that there is currently ongoing work on a redesigned version 2.0 of
Commons Configuration. There has also been some changes in the handling
of list delimiters. I hope that the new design makes it easier to
customize splitting behavior.

Oliver

 
 Cédric
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] how to comment / uncomment particular property in Java *.properties files

2014-04-26 Thread Oliver Heger
Hello,

Am 26.04.2014 18:21, schrieb Shalfey:
 Hello,
 
 I cannot find the functionality for commenting / uncommenting particular
 properties by their names. Let's say I have the property like this:
 
 |app.dateFields=tranDate,expectedCloseDate,\
   closeDate,createdDate,lastModifiedDate,startDate,endDate,\
   salesEffectiveDate,shipDate,actualShipDate,ccExpireDate,\
   revecStartDate,revRecEndDate,validFrom,licenseDateUps,\
   blanketStartDateUps,blanketEndDateUps,shipDateFedEx,\
   homeDeliveryDateFedEx,dueDate,discountDate,billedDate|
 
 I would like to use something like
 
 |propertiesConfigurationLayout.commentProperty(app.dateFields);|
 
 And have the commented property as a result:
 
 |#  app.dateFields=tranDate,expectedCloseDate,\
 #closeDate,createdDate,lastModifiedDate,startDate,endDate,\
 #salesEffectiveDate,shipDate,actualShipDate,ccExpireDate,\
 #revecStartDate,revRecEndDate,validFrom,licenseDateUps,\
 #blanketStartDateUps,blanketEndDateUps,shipDateFedEx,\
 #homeDeliveryDateFedEx,dueDate,discountDate,billedDate|
 
 And I would like to do the same thing to uncomment the property I need.
 
 Is there a way to do this in Apache Commons Configuration? Or there is
 no standard way and I have to implement it on my own?

unfortunately, this feature is not supported. The
PropertiesConfigurationLayout class records comments assigned to a
property. Such comments can be added, changed, or removed. However,
there is no way to transform a property value to a comment or vice versa.

The support for comments mainly has the goal to remain the original
layout of a properties file when it is written again using Commons
Configuration. It does not go so far that comments can be added at
arbitrary positions in the file.

I think, your use case would be an interesting feature to be added to
this library. So if you implement something on your own, it would be
great if you could share your implementation afterwards.

Thanks
Oliver

 
 Initially I have created the topic on stackoverflow
 http://stackoverflow.com/questions/23313323/comment-uncomment-particular-properties-in-java-properties-files-using-apach
 and only after that I've noticed the Mailing List link. Sorry for that.
 
 Thanks in advance,
 
 Sergey
 
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [beanutils]how can I use BeanUtils.populate to set value to my property with diff-argument type between setter and getter?

2014-03-29 Thread Oliver Heger


Am 27.03.2014 05:38, schrieb Yang Diddy:
 Please help:
 if property of my class's setter and setter method arguments type doesn’t 
 match, how can i populate bean object?
 
 public class Foo extends SomeClass{
 private int id;
 
 @Override
 public Object getId() {
   return id;
 }
 
 public void setId(int id) {
this.id = id;
 }
 }
 
 // testing
 Foo foot = new Foo();
 MapString,Object values = new HashMapString,Object();
 values.put(“id”,”1000”);
 BeanUtils.populate(foo, values);
 logger.debug(foo);

Per default, BeanUtils only supports classes complying to the Java Beans
specification. This is obviously not the case for your class.

From version 1.9.x onwards, BeanUtils allows extending the introspection
facilities so that non-conform properties could be detected, too. This
is described in the user guide [1].

I am not sure whether this is an option for you because it requires some
effort to implement a custom BeanIntrospector just to add support for
these properties with incompatible argument types. But AFAIK, this is
the only way to make BeanUtils recognize them.

Oliver

[1]
http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.1/apidocs/org/apache/commons/beanutils/package-summary.html#standard.customize

 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons Configuration Web Site Broken

2014-03-16 Thread Oliver Heger
The site has been redeployed. The problems should be fixed now.

Oliver

Am 14.03.2014 21:35, schrieb Oliver Heger:
 Am 14.03.2014 02:35, schrieb Martin Gainty:

   


 Date: Thu, 13 Mar 2014 14:33:04 +
 Subject: Re: Commons Configuration Web Site Broken
 From: seb...@gmail.com
 To: user@commons.apache.org

 On 12 March 2014 20:27, Oliver Heger oliver.he...@oliver-heger.de wrote:
 Hit Matt,

 thanks for spotting this. It looks like an intermediate snapshot version
 of the site has been deployed while experimenting with the new look  feel.

 Situation is worse because the latest 1.10 release has been made from a
 special branch while the site in trunk still is based on the 1.9 version.


 @Site experts: What is the best option to fix this? I think the approach
 suggested once by sebb would make sense: Create a branch from the 1.10
 release tag, do some modifications (mainly switch to most recent commons
 parent) and deploy from there?
 MGroll 2.x out to a special branch 
 MG(dont allow  trunk to have for more than one experimental branch)
 MGmerge the 1.10 back to trunk
 MGthen cut the 1.10 release candidate
 MGrun your tests including smoke and loadrunner
 MGthen vote on 1.10 being pushed to distros
 MGrelease the 1.10

 MGdiff the 2.0 branch and resolve all insane deltas
 MGrepeat the process enumerated above..
 
 Thanks, Martin!
 
 However, Configuration 1.10 has already been released. This was done
 from a branch created from trunk; then some features and fixes from
 trunk were ported to this branch making the content of the 1.10 release.
 
 So trunk indeed contains the most recent development version; however,
 the most recent site is on the 1.10 release branch.
 
 Oliver
 

 WDYT?

 That the site issue should be discussed in a new mail thread on the
 dev list please.

 Oliver

 Am 12.03.2014 05:36, schrieb Matt Hughes:
 Hi, I'm trying to use commons configuration, but the web site is broken in
 a couple of ways. It references 2.0-SNAPSHOT, and the latest stable 
 version
 it lists is 1.9.

 It doesn't appear to be possible to get to the JavaDoc for 1.9 or 1.10 at
 all.

 The download page and version history page refer to 1.9, but the latest
 release is 1.10, so all of the 1.9 download links are broken.

 It would be helpful for new users of commons configuration to be able to
 access javadoc and download the latest stable release through the web site
 without having to hunt around for the archives... link at the bottom of
 the download page or change the URL to find the 1.10 version.

 Thanks,
 mch


 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org


 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org



 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons Configuration Web Site Broken

2014-03-14 Thread Oliver Heger
Am 14.03.2014 02:35, schrieb Martin Gainty:
 
   
 
 
 Date: Thu, 13 Mar 2014 14:33:04 +
 Subject: Re: Commons Configuration Web Site Broken
 From: seb...@gmail.com
 To: user@commons.apache.org

 On 12 March 2014 20:27, Oliver Heger oliver.he...@oliver-heger.de wrote:
 Hit Matt,

 thanks for spotting this. It looks like an intermediate snapshot version
 of the site has been deployed while experimenting with the new look  feel.

 Situation is worse because the latest 1.10 release has been made from a
 special branch while the site in trunk still is based on the 1.9 version.
 

 @Site experts: What is the best option to fix this? I think the approach
 suggested once by sebb would make sense: Create a branch from the 1.10
 release tag, do some modifications (mainly switch to most recent commons
 parent) and deploy from there?
 MGroll 2.x out to a special branch 
 MG(dont allow  trunk to have for more than one experimental branch)
 MGmerge the 1.10 back to trunk
 MGthen cut the 1.10 release candidate
 MGrun your tests including smoke and loadrunner
 MGthen vote on 1.10 being pushed to distros
 MGrelease the 1.10
 
 MGdiff the 2.0 branch and resolve all insane deltas
 MGrepeat the process enumerated above..

Thanks, Martin!

However, Configuration 1.10 has already been released. This was done
from a branch created from trunk; then some features and fixes from
trunk were ported to this branch making the content of the 1.10 release.

So trunk indeed contains the most recent development version; however,
the most recent site is on the 1.10 release branch.

Oliver

 
 WDYT?

 That the site issue should be discussed in a new mail thread on the
 dev list please.

 Oliver

 Am 12.03.2014 05:36, schrieb Matt Hughes:
 Hi, I'm trying to use commons configuration, but the web site is broken in
 a couple of ways. It references 2.0-SNAPSHOT, and the latest stable version
 it lists is 1.9.

 It doesn't appear to be possible to get to the JavaDoc for 1.9 or 1.10 at
 all.

 The download page and version history page refer to 1.9, but the latest
 release is 1.10, so all of the 1.9 download links are broken.

 It would be helpful for new users of commons configuration to be able to
 access javadoc and download the latest stable release through the web site
 without having to hunt around for the archives... link at the bottom of
 the download page or change the URL to find the 1.10 version.

 Thanks,
 mch


 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org


 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org

 
 


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons Configuration Web Site Broken

2014-03-12 Thread Oliver Heger
Hit Matt,

thanks for spotting this. It looks like an intermediate snapshot version
of the site has been deployed while experimenting with the new look  feel.

Situation is worse because the latest 1.10 release has been made from a
special branch while the site in trunk still is based on the 1.9 version.

@Site experts: What is the best option to fix this? I think the approach
suggested once by sebb would make sense: Create a branch from the 1.10
release tag, do some modifications (mainly switch to most recent commons
parent) and deploy from there?

WDYT?
Oliver

Am 12.03.2014 05:36, schrieb Matt Hughes:
 Hi, I'm trying to use commons configuration, but the web site is broken in
 a couple of ways. It references 2.0-SNAPSHOT, and the latest stable version
 it lists is 1.9.
 
 It doesn't appear to be possible to get to the JavaDoc for 1.9 or 1.10 at
 all.
 
 The download page and version history page refer to 1.9, but the latest
 release is 1.10, so all of the 1.9 download links are broken.
 
 It would be helpful for new users of commons configuration to be able to
 access javadoc and download the latest stable release through the web site
 without having to hunt around for the archives... link at the bottom of
 the download page or change the URL to find the 1.10 version.
 
 Thanks,
 mch
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons configuration version 2

2014-02-25 Thread Oliver Heger
Some more comments from me in-line...

Am 25.02.2014 14:17, schrieb Gary Gregory:
 Yair,
 
 Welcome to Apache Commons.
 
 Please see:
 
 1- https://commons.apache.org/volunteering.html
 2- https://commons.apache.org/patches.html
 3- https://commons.apache.org/building.html
 4-
 https://commons.apache.org/proper/commons-configuration/source-repository.html
 
 1. Is there any snapshot repository available?
 See 4 above.
 
 2. Which percentage of the work is already done in your opinion?
 I do not know.
From a functionality point of view the major part of the work for
version 2.0 is done. However, currently I started a refactoring of
hierarchical configurations which turns out to be bigger than expected.
After this is finished, there are still some minor improvements and some
polishing. And of course, the user guide has to be updated, and a
migration guide should be created.

 
 3. How does this effort differ from the 1.x branch?
 I do not know.
Main differences are:
- Configurations are now created via builders
- The reloading mechanism was redesigned
- Improvements in the area of thread-safety and concurrent access

Oliver

 
 Isn't that also supported on volunteering basis?
 Yes, we are volunteers.
 
 This Mailing List (ML) is the best place to ask questions, do not hesitate
 to ask and make some noise ;)
 
 Gary
 
 
 
 On Tue, Feb 25, 2014 at 12:19 AM, Yair Ogen yairo...@gmail.com wrote:
 
 I may be able to contribute.

 1. Is there any snapshot repository available?
 2. Which percentage of the work is already done in your opinion?
 3. How does this effort differ from the 1.x branch? Isn't that also
 supported on volunteering basis?

 Thanks
 On Feb 24, 2014 10:37 PM, Oliver Heger oliver.he...@oliver-heger.de
 wrote:

 Hi Yair,

 thanks for your interest in Commons Configuration.

 Unfortunately, I cannot be more precise than Gary. There is still
 ongoing work on a major refactoring of the API for Configuration 2.0.
 There is some progress, but it is slow as time for OpenSource is limited.

 There is no detailed road map. The closest analog is Jira [1], our
 ticket system, listing the tasks to be done for the release. However,
 this list is not easy to interpret because it contains bug reports,
 improvements, wishes, and refactoring tasks in a mix.

 HTH
 Oliver

 [1]

 http://commons.apache.org/proper/commons-configuration/issue-tracking.html

 Am 24.02.2014 20:56, schrieb Yair Ogen:
 Thanks, is there some road map somewhere?
 On Feb 24, 2014 8:21 PM, Gary Gregory garydgreg...@gmail.com
 wrote:

 Yiar,

 There is no release date planned as of yet. The work is done by
 volunteers
 here. SNAPSHOT builds are not uploaded regularly, you best bet is to
 download trunk and build it locally.

 Hopefully someone else will chime in WRT a release timeline.

 Gary


 On Mon, Feb 24, 2014 at 1:06 PM, Yair Ogen yairo...@gmail.com
 wrote:

 Does anyone know when Apache commons configuration version 2 will be
 released? Even trying to download a maven snapshot is hard to come
 buy.




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory



 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org



 
 
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons configuration version 2

2014-02-25 Thread Oliver Heger


Am 25.02.2014 22:04, schrieb Gary Gregory:
 We could also migrate to the current version of Commons Digester.
Hm, not sure whether this dependency is still needed at all. IIRC, it
was used by a deprecated class which could now be removed.

Oliver

 
 Gary
 
 
 On Tue, Feb 25, 2014 at 4:01 PM, Oliver Heger
 oliver.he...@oliver-heger.dewrote:
 
 Some more comments from me in-line...

 Am 25.02.2014 14:17, schrieb Gary Gregory:
 Yair,

 Welcome to Apache Commons.

 Please see:

 1- https://commons.apache.org/volunteering.html
 2- https://commons.apache.org/patches.html
 3- https://commons.apache.org/building.html
 4-

 https://commons.apache.org/proper/commons-configuration/source-repository.html

 1. Is there any snapshot repository available?
 See 4 above.

 2. Which percentage of the work is already done in your opinion?
 I do not know.
 From a functionality point of view the major part of the work for
 version 2.0 is done. However, currently I started a refactoring of
 hierarchical configurations which turns out to be bigger than expected.
 After this is finished, there are still some minor improvements and some
 polishing. And of course, the user guide has to be updated, and a
 migration guide should be created.


 3. How does this effort differ from the 1.x branch?
 I do not know.
 Main differences are:
 - Configurations are now created via builders
 - The reloading mechanism was redesigned
 - Improvements in the area of thread-safety and concurrent access

 Oliver


 Isn't that also supported on volunteering basis?
 Yes, we are volunteers.

 This Mailing List (ML) is the best place to ask questions, do not
 hesitate
 to ask and make some noise ;)

 Gary



 On Tue, Feb 25, 2014 at 12:19 AM, Yair Ogen yairo...@gmail.com wrote:

 I may be able to contribute.

 1. Is there any snapshot repository available?
 2. Which percentage of the work is already done in your opinion?
 3. How does this effort differ from the 1.x branch? Isn't that also
 supported on volunteering basis?

 Thanks
 On Feb 24, 2014 10:37 PM, Oliver Heger oliver.he...@oliver-heger.de
 wrote:

 Hi Yair,

 thanks for your interest in Commons Configuration.

 Unfortunately, I cannot be more precise than Gary. There is still
 ongoing work on a major refactoring of the API for Configuration 2.0.
 There is some progress, but it is slow as time for OpenSource is
 limited.

 There is no detailed road map. The closest analog is Jira [1], our
 ticket system, listing the tasks to be done for the release. However,
 this list is not easy to interpret because it contains bug reports,
 improvements, wishes, and refactoring tasks in a mix.

 HTH
 Oliver

 [1]


 http://commons.apache.org/proper/commons-configuration/issue-tracking.html

 Am 24.02.2014 20:56, schrieb Yair Ogen:
 Thanks, is there some road map somewhere?
 On Feb 24, 2014 8:21 PM, Gary Gregory garydgreg...@gmail.com
 wrote:

 Yiar,

 There is no release date planned as of yet. The work is done by
 volunteers
 here. SNAPSHOT builds are not uploaded regularly, you best bet is to
 download trunk and build it locally.

 Hopefully someone else will chime in WRT a release timeline.

 Gary


 On Mon, Feb 24, 2014 at 1:06 PM, Yair Ogen yairo...@gmail.com
 wrote:

 Does anyone know when Apache commons configuration version 2 will be
 released? Even trying to download a maven snapshot is hard to come
 buy.




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory



 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org







 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org


 
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons configuration version 2

2014-02-24 Thread Oliver Heger
Hi Yair,

thanks for your interest in Commons Configuration.

Unfortunately, I cannot be more precise than Gary. There is still
ongoing work on a major refactoring of the API for Configuration 2.0.
There is some progress, but it is slow as time for OpenSource is limited.

There is no detailed road map. The closest analog is Jira [1], our
ticket system, listing the tasks to be done for the release. However,
this list is not easy to interpret because it contains bug reports,
improvements, wishes, and refactoring tasks in a mix.

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/issue-tracking.html

Am 24.02.2014 20:56, schrieb Yair Ogen:
 Thanks, is there some road map somewhere?
 On Feb 24, 2014 8:21 PM, Gary Gregory garydgreg...@gmail.com wrote:
 
 Yiar,

 There is no release date planned as of yet. The work is done by volunteers
 here. SNAPSHOT builds are not uploaded regularly, you best bet is to
 download trunk and build it locally.

 Hopefully someone else will chime in WRT a release timeline.

 Gary


 On Mon, Feb 24, 2014 at 1:06 PM, Yair Ogen yairo...@gmail.com wrote:

 Does anyone know when Apache commons configuration version 2 will be
 released? Even trying to download a maven snapshot is hard to come buy.




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory

 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Help on implementing new Configuration (JSON)

2014-02-20 Thread Oliver Heger
Hi Thomas,

Am 20.02.2014 13:30, schrieb Thomas Melville:
 Hi,
 
 Is there any documentation on implementing a new configuration?
 In our system we have properties in .properties file and .json files and I
 don't see anything about JSON in apache-commons-configuration.
 
 I'd like to implement a JSONConfiguration but I'm unsure where to start.
 
 I thought about extending the Propertiesconfiguration and overriding the
 createLayout.
 I also thought about extending the AbstractFileConfiguration.

there has been some work on a JSONConfiguration on an experimental
branch a longer time ago [1]. I don't know how complete this code is,
but maybe it gives you a good starting point for your own implementation.

The class to inherit from depends on your implementation.
AbstractFileConfiguration is the most generic one if you do basic
reading and writing of files.

We would also be interested in a JSONConfiguration implementation. So if
you could check out the stuff on the experimental branch or come up with
your own implementation, contributions in this area would be welcome!

HTH
Oliver

[1]
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/json/

 
 BR
 Thomas
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Conditional Configuration Keys

2014-02-13 Thread Oliver Heger
Hi Ron,

Am 13.02.2014 20:53, schrieb DiFrango, Ronald (CONT):
 All,
 
 I searched around and could find an answer, I have a set of properties where 
 I want to conditionally select them based upon environment variables.  For 
 example, I have the following set:
 
 schemas.default=DB
 schemas.perf=PERF
 schemas.qa=QA
 schemas.int=INT
 
 And I would like to do something to the effect of:
 
 If (env.variable == 'qa')
 schemas=QA
 else If (env.variable == 'perf')
 schemas=PERF
 else If (env.variable == 'int)
 schemas=int
 else
 schemas=DB
 
 The way I accomplished this today is that I created an AOP interceptor that 
 does this work and when the clients request schema it does this logic.
 
 My preference would be to handle this during property loading time.  Are 
 there any extensions where I could do such a thing?

You might want to have a look at multi-tenant configurations [1]. If I
understand you correctly, this feature solves your problem. It is
possible to access different configuration sources based on interpolated
properties. System properties or environment variables can also be used
to determine the set of properties available.

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_multitenant.html#Multi-tenant_Configurations

 
 Thanks,
 
 Ron
 
 
 
 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith is 
 intended only for use by the individual or entity to which it is addressed.  
 If the reader of this message is not the intended recipient, you are hereby 
 notified that any review, retransmission, dissemination, distribution, 
 copying or other use of, or taking of any action in reliance upon this 
 information is strictly prohibited. If you have received this communication 
 in error, please contact the sender and delete the material from your 
 computer.
 

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Conditional Configuration Keys

2014-02-13 Thread Oliver Heger
Hi Ron,

Am 13.02.2014 21:28, schrieb DiFrango, Ronald (CONT):
 Oliver,
 
 Thanks for that reference, and while that is somewhat helpful it means that 
 for each environment, we still need a separate properties file for each of 
 the environments and another one for the common stuff.  Previously, we had 
 accomplished this before by conditionally loading files based upon path 
 within our XML file like:
 
   properties
   
 fileName=${config.root}/test-app/environment/${config.env}/test.properties
   listDelimiter=|
   reloadingStrategy refreshDelay=1
   
 config-class=org.apache.commons.configuration.reloading.FileChangedReloadingStrategy
  /
   /properties
 
 My hope was to find a way to do that a little bit more concisely within a 
 single file or as I mentioned hooking into the property loading process.

your current solution based on a DefaultConfigurationBuilder and
interpolated variables is more or less the recommended way for your use
case. I don't think that this can be much improved.

If you only use properties files, an option could be using the include
directive [1] in a clever way. Here you can use variables, too.

There is also the possibility to set an IOFactory on a
PropertiesConfiguration. This factory is used for creating an input
stream to the file to read. But it is more intended for adapting the
format to be parsed and not for selecting different sets of properties.

Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_properties.html#Includes

 
 Thanks,
 
 Ron
 
 -Original Message-
 From: Oliver Heger [mailto:oliver.he...@oliver-heger.de] 
 Sent: Thursday, February 13, 2014 3:14 PM
 To: Commons Users List
 Subject: Re: Conditional Configuration Keys
 
 Hi Ron,
 
 Am 13.02.2014 20:53, schrieb DiFrango, Ronald (CONT):
 All,

 I searched around and could find an answer, I have a set of properties where 
 I want to conditionally select them based upon environment variables.  For 
 example, I have the following set:

 schemas.default=DB
 schemas.perf=PERF
 schemas.qa=QA
 schemas.int=INT

 And I would like to do something to the effect of:

 If (env.variable == 'qa')
 schemas=QA
 else If (env.variable == 'perf')
 schemas=PERF
 else If (env.variable == 'int)
 schemas=int
 else
 schemas=DB

 The way I accomplished this today is that I created an AOP interceptor that 
 does this work and when the clients request schema it does this logic.

 My preference would be to handle this during property loading time.  Are 
 there any extensions where I could do such a thing?
 
 You might want to have a look at multi-tenant configurations [1]. If I 
 understand you correctly, this feature solves your problem. It is possible to 
 access different configuration sources based on interpolated properties. 
 System properties or environment variables can also be used to determine the 
 set of properties available.
 
 HTH
 Oliver
 
 [1]
 http://commons.apache.org/proper/commons-configuration/userguide/howto_multitenant.html#Multi-tenant_Configurations
 

 Thanks,

 Ron

 

 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith 
 is intended only for use by the individual or entity to which it is 
 addressed.  If the reader of this message is not the intended recipient, you 
 are hereby notified that any review, retransmission, dissemination, 
 distribution, copying or other use of, or taking of any action in reliance 
 upon this information is strictly prohibited. If you have received this 
 communication in error, please contact the sender and delete the material 
 from your computer.

 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org
 
 
 
 The information contained in this e-mail is confidential and/or proprietary 
 to Capital One and/or its affiliates. The information transmitted herewith is 
 intended only for use by the individual or entity to which it is addressed.  
 If the reader of this message is not the intended recipient, you are hereby 
 notified that any review, retransmission, dissemination, distribution, 
 copying or other use of, or taking of any action in reliance upon this 
 information is strictly prohibited. If you have received this communication 
 in error, please contact the sender and delete the material from your 
 computer.
 
 
 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org

Re: [configuration] INIConfiguration has no include?

2014-01-17 Thread Oliver Heger
Hello Hans,

Am 17.01.2014 10:48, schrieb Hans Schwäbli:
 When using the org.apache.commons.configuration.PropertiesConfiguration
 there is a include feature allowing me to include other property files.
 
 I use this for overriding default properties with user's specific
 properties: include=configuration_${sys:user.name}.cfg
 
 Now I want to use org.apache.commons.configuration.INIConfiguration in
 another project because then I can use sections. But there seems to be no
 include feature when using that INIConfiguration.
 
 Do I have to code that feature myself when using the INIConfiguration or
 did I overlook how it works?
 
There is indeed no support for includes in INIConfiguration. The
recommended way for combining the data of multiple configuration sources
is to use the DefaultConfigurationBuilder [1] class. It allows you to
construct a hierarchical configuration from child configurations of
different types.

HTH
Oliver

[1]
http://commons.apache.org/proper/commons-configuration/userguide/howto_configurationbuilder.html

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons BeanUtils 1.9.1 Released

2014-01-12 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons BeanUtils 1.9.1.

The Apache Commons BeanUtils library is a component that provides easy
to use wrappers around the Java Reflection and Introspection capabilities.

Release 1.9.1 is a bug fix release which solves a problem with a new
feature introduced in version 1.9.0. A full list of all changes can be
found in the release notes at
  http://www.apache.org/dist/commons/beanutils/RELEASE-NOTES.txt

Source and binary distributions are available for download from the
Apache Commons download site:
  http://commons.apache.org/proper/commons-beanutils/download_beanutils.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release.

For complete information on Commons BeanUtils, including instructions
on how to submit bug reports, patches, or suggestions for improvement,
see the Apache Commons BeanUtils website:

http://commons.apache.org/proper/commons-beanutils/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons BeanUtils 1.9.0 Released

2013-12-12 Thread Oliver Heger
The Apache Commons Team is pleased to announce the availability of
Apache Commons BeanUtils 1.9.0.

The Apache Commons BeanUtils library is a component that provides easy
to use wrappers around the Java Reflection and Introspection capabilities.

Release 1.9.0 contains some bug fixes and improvements that have
accumulated after the 1.8.3 release. The most obvious change is that the
new version now requires JDK 1.5 or higher, and that language features
introduced with Java 5 (mainly generics) are used. A full list of all
changes can be found in the release notes at
  http://www.apache.org/dist/commons/beanutils/RELEASE-NOTES.txt

Source and binary distributions are available for download from the
Apache Commons download site:
  http://commons.apache.org/proper/commons-beanutils/download_beanutils.cgi

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release.

For complete information on Commons BeanUtils, including instructions
on how to submit bug reports, patches, or suggestions for improvement,
see the Apache Commons BeanUtils website:

http://commons.apache.org/proper/commons-beanutils/

Oliver Heger, on behalf of the Apache Commons community

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] when is commons configuration 2.0 is planned to be released?

2013-09-27 Thread Oliver Heger
Hi Dmitriy,

thanks for your interest in Commons Configuration.

Am 27.09.2013 13:08, schrieb Dmitriy Litvak:
 Configuration commons 2.0 has been sitting in svn for more than a year.
 Are there plans to release it soon?
 
 Thank you!
 D
 

Well, there is still some work to do. On my to-do list, there is at
least one major point (a mechanism to define default settings for
configurations) and some minor things. Not to forget, documentation has
to be updated, and a migration guide to be provided.

Note that version 2.0 is not compatible with the 1.x series, some parts
of the library have been redesigned. Because of this, there will be an
alpha release first in order to gain feedback from users. I *hope* that
this can be done until the end of this year, but I cannot promise.

It would be great if you could comment on the changed API and what is
still missing. However, due to the outdated documentation, this is
probably not too easy.

Hope this answers your question
Oliver


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[configuration] Re: commons-configuration question

2013-07-22 Thread Oliver Heger
Hello Brian,

Am 22.07.2013 18:48, schrieb Brian McCormick:
 I hope I am asking in the right place. I could not find a user group per se
 that supports this. Please point me in the right direction if this isn't a
 good place to ask questions.
 
yes, this is the correct place. However, this is a shared list for all
Commons components. Therefore, convention is to prefix the subject with
the name of the component you are interested in (as I have done).

  
 
 I am evaluating whether to use the commons-configuration in my development
 as opposed to the java Preferences API. The 1.0 version of the app has
 already been released with the user preferences stored using Java
 Preferences API. 
 
  
 
 Does the commons-configuration API support the formats used by the java
 Preferences API? It looks like it provides interoperability with the java
 Properties API but I didn't see anything about the Preferences API.
 
I assume you would like to access a Preferences object through the
Configuration interface? Unfortunately, this is currently not supported.
There is an implementation of such a class in an experimental branch,
but it is not mature or in a shape to be released.

Sorry
Oliver
  
 
 thanks
 
  
 
 Brian S. McCormick
 
 mcc...@cox.net
 
 918-749-5453
 
  
 
 


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Intenttion of class FileBased

2013-05-05 Thread Oliver Heger

Hi Oliver,

great to get some feedback on the new re-designed trunk!

Am 05.05.2013 01:17, schrieb Oliver Kopp:

Hi,

I'm working with the trunk version of apache.commons.configuration. There,
FileHandler allows to have passed a FileBased object in the constructor.
I thought, I could implement that interface to provide an abstraction to
the underlying file system. However, if I do it htat way, there is an
exception No file name has been set!. When going through the code, it
seems that this object is the internal data storage for the configuration
and not the external file storage.

Possibly, just the header comments of this constructor should be updated.
Like sort of saying this constructor is for internal use only.


The purpose of FileHandler is to manage a file description in various 
formats (File, URL, file name, etc.). It can be associated with a 
FileBased object which has a read() and a write() method and thus more 
or less defines the content of the file.


The typical usage scenario is that you create a FileHandler and 
associate it with a FileBased object (all file-based configurations now 
implement this interface). Then you use some of the set() methods to 
define the file name. Finally, you can call load() to get the FileBased 
object loaded. Alternatively, you can use one of the load() methods 
expecting a parameter (again various parameter types are supported).


There is still the FileSystem class which provides an abstraction over 
concrete file operations. So this is probably the class you are after. 
(Note: I plan to move this class also into the io package. And maybe it 
can be a bit simplified.)


HTH
Oliver



Cheers,

Oliver




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] CombinedConfiguration#clone() not cloning changed properties

2012-12-05 Thread Oliver Heger

Am 05.12.2012 16:32, schrieb Andre Weihe:

CombinedConfiguration#clone() does not clone properties set/changed on the 
CombinedConfiguration that are stored in combinedRoot (which seems NOT to be 
cloned).

Bug, feature or You are using it wrong!?


Probably a kind of missing feature...

This seems to be the same problem as for updates of a 
CombinedConfiguration as described in the user's guide [1].


When the CombinedConfiguration is cloned, its nodes structure is not 
cloned, but only the list of child configurations. (From these 
configurations the nodes tree is constructed again.) If changes were 
made which could not be assigned to one of the source configurations, 
they are lost.


I guess, a specific strategy has to be defined how to handle updates of 
a CombinedConfiguration in general. Currently, it is certainly not ideal.


Oliver

[1] 
http://commons.apache.org/configuration/userguide/howto_combinedconfiguration.html#Dealing_with_changes



Demonstration program:
import org.apache.commons.configuration.*;
import org.apache.commons.configuration.tree.OverrideCombiner;
import java.util.Iterator;

public class CommonsConfigurationTester {
 private static final String FOO_KEY = Test.foo;
 private static final String BAR_KEY = Test.bar;

 public static void main(String[] args) {
 new CommonsConfigurationTester().ccTest();
 }

 void ccTest() {
 HierarchicalConfiguration defaultConfig = new 
HierarchicalConfiguration();
 defaultConfig.addProperty(FOO_KEY, Integer.valueOf(1));
 defaultConfig.addProperty(BAR_KEY, Integer.valueOf(2));

 System.out.println(Default config:\n + 
configToString(defaultConfig));

 HierarchicalConfiguration individualConfig = new 
HierarchicalConfiguration();
 individualConfig.addProperty(FOO_KEY, Integer.valueOf(3));
 individualConfig.addProperty(BAR_KEY, Integer.valueOf(4));

 System.out.println(Individual config (has precedence):\n + 
configToString(individualConfig));

 CombinedConfiguration combinedConfig = new CombinedConfiguration(new 
OverrideCombiner());
 combinedConfig.addConfiguration(individualConfig);
 combinedConfig.addConfiguration(defaultConfig);

 System.out.println(Combined config (default + individual):\n + 
configToString(combinedConfig));

 combinedConfig.setProperty(FOO_KEY, Integer.valueOf(5));
 combinedConfig.setProperty(BAR_KEY, Integer.valueOf(6));

 System.out.println(Changed config (default + individual):\n + 
configToString(combinedConfig));

 CombinedConfiguration combinedConfig2 = 
(CombinedConfiguration)combinedConfig.clone();

 System.out.println(Cloned changed config (default + individual):\n + 
configToString(combinedConfig2));
 }


 /**
  * A little helper method to get all the settings of a configuration into 
a String
  * @param config the Configuration whose String representation we want
  * @return a String containing the key-value pairs
  */
 static String configToString(Configuration config) {
 String pairs = new String();
 for (Iterator keys = config.getKeys(); keys.hasNext();) {
 String key = (String)keys.next();
 pairs = pairs + key + '=' + config.getProperty(key) + '\n';
 }

 return pairs;
 }
}




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] ACC is inserting and removing backslahes

2012-10-13 Thread Oliver Heger

Am 12.10.2012 21:04, schrieb Jamie Salts:

Hello,

I am attempting to use commons configuration with some existing
properties files I have and I'm noticing my backslashes in password
hashes and file locations are being removed and some of my quotes get
escaped when simply loading and saving the file. This caused one of my
password hashes to change. Is there any way to manage this
functionality?

Which version of Commons Configuration do you use? And could you provide 
an example of a properties file which gets corrupted by loading and saving?


Oliver


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration]: getList

2012-09-25 Thread Oliver Heger

Am 25.09.2012 20:13, schrieb Rainer Hirschmiller:

Hi,

I use a properties file for configuration which contains a list of
integer values.

Retrieving the List I got a list of string instead of a list of integer.
The question now is how can I get a list of integers instead.


So far, data conversion only works for single values, I am afraid. But 
this would be a good feature request. For the next major release there 
are some thoughts about an enhanced converter framework.


Oliver



Rainer

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [lang] commons-lang 3.1 and commons-configuration

2012-08-11 Thread Oliver Heger

Am 10.08.2012 14:12, schrieb Tom Weissinger:

Oliver,

Thanks for the information.

Is the expectation that commons-configuration will undergo the same sort of
change, where all the package names change to have configuration2 like
what was done with lang3?


Yes, both the package names and the Maven coordinates will change. In 
our opinion this is the only way to avoid jar hell.


Oliver



Tom

On Wed, Aug 8, 2012 at 3:38 PM, Oliver Heger
oliver.he...@oliver-heger.dewrote:


Hi Tom,

Am 07.08.2012 22:21, schrieb Tom Weissinger:

  Hi,


What is the timeline for commons-configuration to be compatible with
commons-lang 3.1?  We want to be able to use some of the new features of
commons-lang (like generic support) but commons-configuration still uses
the old commons-lang.

The end result is, if we use the latest versions of both libraries, we end
up pulling into 2 different versions of commons-lang JAR.  I don't see
this
as a big deal, but if that in itself is an issue, please let me know.

My primary question though is, when will commons-configuration support
commons-lang 3.1?  What is holding it back?  Just people to work on it?

Thanks!
Tom

  the main problem with support for commons-lang 3.x in

commons-configuration is that classes from commons-lang are part of the
public API of commons-configuration. Our release policy demands that a
change in the public API requires a major release - minor releases have to
be binary compatible.

Our original plan was to do some major API cleanup and redesign for the
next Configuration major release. But this will probably take too long.
Therefore, my intension is to release Configuration 1.9 (the current trunk
version which still depends on commons-lang 2.6) in the next few weeks, and
then prepare a major release with support for the most recent lang version
and some minor cleanup only. I hope that this will take place in the nearer
future, but cannot present a concrete time schedule.

In the meanwhile: It is no problem for the two versions of commons-lang to
co-exist. This scenario had been anticipated, and therefore it was ensured
that there are no conflicts.

Oliver


--**--**-
To unsubscribe, e-mail: 
user-unsubscribe@commons.**apache.orguser-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org







-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [lang] commons-lang 3.1 and commons-configuration

2012-08-08 Thread Oliver Heger

Hi Tom,

Am 07.08.2012 22:21, schrieb Tom Weissinger:

Hi,

What is the timeline for commons-configuration to be compatible with
commons-lang 3.1?  We want to be able to use some of the new features of
commons-lang (like generic support) but commons-configuration still uses
the old commons-lang.

The end result is, if we use the latest versions of both libraries, we end
up pulling into 2 different versions of commons-lang JAR.  I don't see this
as a big deal, but if that in itself is an issue, please let me know.

My primary question though is, when will commons-configuration support
commons-lang 3.1?  What is holding it back?  Just people to work on it?

Thanks!
Tom

the main problem with support for commons-lang 3.x in 
commons-configuration is that classes from commons-lang are part of the 
public API of commons-configuration. Our release policy demands that a 
change in the public API requires a major release - minor releases have 
to be binary compatible.


Our original plan was to do some major API cleanup and redesign for the 
next Configuration major release. But this will probably take too long. 
Therefore, my intension is to release Configuration 1.9 (the current 
trunk version which still depends on commons-lang 2.6) in the next few 
weeks, and then prepare a major release with support for the most recent 
lang version and some minor cleanup only. I hope that this will take 
place in the nearer future, but cannot present a concrete time schedule.


In the meanwhile: It is no problem for the two versions of commons-lang 
to co-exist. This scenario had been anticipated, and therefore it was 
ensured that there are no conflicts.


Oliver


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] attributes in xml config don't apply to all entries of a list

2012-05-31 Thread Oliver Heger

Am 31.05.2012 08:30, schrieb Alexander Selg:

Hi Oliver,

thanks for your clarification.

 From my point of view it would be more straightforward assigning
attributes to all nodes of a list. Otherwise the list feature seems
incomlete to me.
Our lists are a bit longish so I was very happy that I can avoid
repeating tags in our config.xml.

Does it make sense to create an improvement issue?


Why not? However, I think this issue will not be dealt with in an 1.x 
version because it might break existing code.


For Configuration 2.x list handling and list delimiter parsing are 
certainly topics which can be improved.


Oliver



Otherwise I think I would prefer to read the list as string and parse
it as a list by myself ...

Thank you for your help,
Alex

2012/5/30 Oliver Hegeroliver.he...@oliver-heger.de:

Am 30.05.2012 16:53, schrieb Alexander Selg:


Hi,

I'm using a different implementation of the DefaultExpressionEngine. I
use attributes in our applications conf.xml to filter the result of
DefaultExpressionEngine.query().
So I have a config file like

configuration
someStrings environment=teststr1,str2,str3/someStrings
someStrings environment=prodstr4,str5,str6/someStrings
/configuration

In the query() methode of MyExpressionEngine I want to access these
attributes

ListConfigurationNodequeryResults = super.query(root, key);
for (ConfigurationNode queryResult : queryResults) {
attributes = queryResult.getAttributes();
...
}

The problem is that I only get the attributes for the first node - the
subsequent nodes don't have any attributes set.
So for str1 I'll get the attribute environment=test, for str2
and str3 I'll get no attributes.

Is that a bug?
Am I doing something wrong?

I'm using commons-configuration 1.8 with jdk1.6

Any help would be appreciated,
Alex



Not sure whether this behavior is somewhere documented, but it is indeed
intended. There are unit tests for XMLConfiguration which test that
attributes are only assigned to the first node of a list.

I guess, there are different use cases. When the code was developed a
decision had to be taken. At that time assigning attributes only to the
first node seemed to be straightforward.

If you have any control over your XML, I would recommend to avoid
comma-separated properties with multiple values. In XML lists can be defined
in a natural way by just repeating tags. Then the association between
attributes and values nodes is obvious.

HTH
Oliver



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] attributes in xml config don't apply to all entries of a list

2012-05-30 Thread Oliver Heger

Am 30.05.2012 16:53, schrieb Alexander Selg:

Hi,

I'm using a different implementation of the DefaultExpressionEngine. I
use attributes in our applications conf.xml to filter the result of
DefaultExpressionEngine.query().
So I have a config file like

configuration
someStrings environment=teststr1,str2,str3/someStrings
someStrings environment=prodstr4,str5,str6/someStrings
/configuration

In the query() methode of MyExpressionEngine I want to access these attributes

ListConfigurationNode  queryResults = super.query(root, key);
for (ConfigurationNode queryResult : queryResults) {
attributes = queryResult.getAttributes();
...
}

The problem is that I only get the attributes for the first node - the
subsequent nodes don't have any attributes set.
So for str1 I'll get the attribute environment=test, for str2
and str3 I'll get no attributes.

Is that a bug?
Am I doing something wrong?

I'm using commons-configuration 1.8 with jdk1.6

Any help would be appreciated,
Alex


Not sure whether this behavior is somewhere documented, but it is indeed 
intended. There are unit tests for XMLConfiguration which test that 
attributes are only assigned to the first node of a list.


I guess, there are different use cases. When the code was developed a 
decision had to be taken. At that time assigning attributes only to the 
first node seemed to be straightforward.


If you have any control over your XML, I would recommend to avoid 
comma-separated properties with multiple values. In XML lists can be 
defined in a natural way by just repeating tags. Then the association 
between attributes and values nodes is obvious.


HTH
Oliver



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] best practice with nested xml files

2012-05-02 Thread Oliver Heger

Am 01.05.2012 13:07, schrieb Oliver Zemann:

Hi

following scenario:

I have one global config.xml which contains a regularconfiguration
and includes some furtherconfiguration fileName=a1.xml /
configuration fileName=a2.xml /  ...
The a1.xml also contains some xml references likexml
fileName=a1_1.xml /  xml fileName=a1_2.xml /  ... which the user
can input.
What is now the best practice to access these fields when i dont know
the filenames (a1_1.xml, a1_2.xml, ...)? I only know that they have a
root xml tag calleda1

At the moment i read in a CombinedConfiguration from my config.xml and
use SubnodeConfiguration with getString([@fileName]), iterate over
that and create for each a SubnodeConfiguration, but i think this is a
code smell because if someone puts a1_1.xml (the xml block) into
a1.xml (which still leads to valid xml) it wont work anymore because i
reference directly to that file and not only to the field. So the user
must always usexml fileName=... /.

Furthermore i only need a1_1.xml in a class for identification. Lets
assume i have a fieldpassword  in a1_1.xml and in a1_2.xml. Both xml
files start witha1.
First i thought just create a CombinedConfiguration and pass it down
to all methods so i can access the configuration from everywhere. But
the problem is one class needs to know if it should now take a1_1.xml
or a1_2.xml. At the moment (as mentioned before) i pass a
SubnodeConfiguration to my class in its constructor and access its
field that way.

Any help is appreciated.
Thanks!


Sorry, but I don't really understand what you want to achieve. Maybe you 
can elaborate some more on the use case?


Just one suggestion (with limited understanding of your issue): Can you 
assign names to the included child configurations (using the config-name 
attribute) and then ask the combined configuration for specific sub 
configurations? CombinedConfiguration has the methods 
getConfigurationNames() and getConfiguration(String name).


Oliver



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Problem with XMLConfiguration.setProperty(String, Object) and setDelimiterParsingDisabled

2012-04-25 Thread Oliver Heger

Am 22.04.2012 22:15, schrieb Oliver Heger:

Thank you for reporting this. I agree with you that the output of the
configuration should be independent on the value of the delimiter
parsing flag.

If you are convinced that this is an error, please open a ticket in our
bug tracking system [1].

I hope to find some time in the next days to have a look at this issue.


This is indeed a bug. It actually affects all Configuration implementations.

I opened the following bug report:
https://issues.apache.org/jira/browse/CONFIGURATION-495

Oliver



Oliver

[1] http://commons.apache.org/configuration/issue-tracking.html

Am 22.04.2012 13:38, schrieb thc...@gmail.com:

Hi.

Sorry for the code not properly indented (content of
DelimiterExample.java).

Here it goes again:

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;

public class DelimiterExample
{
// Configuration file that will have the
// setDelimiterParsingDisabled as _false_.
private static final String CONF_DELIMITER_ENABLED_XML =
ConfDelimiterEnabled.xml;

// Configuration file that will have the
// setDelimiterParsingDisabled as_true_.
private static final String CONF_DELIMITER_DISABLED_XML =
ConfDelimiterDisabled.xml;

// Key of the data used in the configuration files.
private static final String LIST_ELEMENT_KEY = list.element;

public static void main(String[] args) throws ConfigurationException
{
// Data that will be saved in the configuration files.
ListString data = new ArrayListString(3);
data.add(value 1);
data.add(value 2);
data.add(value 3);


// First using setDelimiterParsingDisabled as false.

XMLConfiguration confDelimiterEnabledWrite =
new XMLConfiguration(CONF_DELIMITER_ENABLED_XML);

confDelimiterEnabledWrite.setProperty(LIST_ELEMENT_KEY, data);
// Writes:
//list
//elementvalue 1/element
//elementvalue 2/element
//elementvalue 3/element
///list

confDelimiterEnabledWrite.save();

XMLConfiguration confDelimiterEnabledRead =
new XMLConfiguration(CONF_DELIMITER_ENABLED_XML);
String[] values =
confDelimiterEnabledRead.getStringArray(LIST_ELEMENT_KEY);

// Doesn't output anything as they are equals. Expected behaviour.
if (!Arrays.equals(values, data.toArray()))
{
System.out.println(
setDelimiterParsingDisabled(false): Data not equal!);
}


// Now using setDelimiterParsingDisabled as true.

XMLConfiguration confDelimiterDisabledWrite = new XMLConfiguration();
confDelimiterDisabledWrite.setDelimiterParsingDisabled(true);
confDelimiterDisabledWrite.setFileName(CONF_DELIMITER_DISABLED_XML);
confDelimiterDisabledWrite.load();

confDelimiterDisabledWrite.setProperty(LIST_ELEMENT_KEY, data);
// Writes:
//list
//element[value 1, value 2, value 3]/element
///list

// Unexpected behaviour!
// Shouldn't it write the same as with
// setDelimiterParsingDisabled as false? as it is a list.

confDelimiterDisabledWrite.save();

XMLConfiguration confDelimiterDisabledRead = new XMLConfiguration();
confDelimiterDisabledRead.setDelimiterParsingDisabled(true);
confDelimiterDisabledRead.setFileName(CONF_DELIMITER_DISABLED_XML);
confDelimiterDisabledRead.load();

values = confDelimiterDisabledRead.getStringArray(LIST_ELEMENT_KEY);

// As it writes other thing this will output that they are not equals.
if (!Arrays.equals(values, data.toArray()))
{
System.out.println(
setDelimiterParsingDisabled(true): Data not equal!);
}
}

}


Best regards.




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Problem with XMLConfiguration.setProperty(String, Object) and setDelimiterParsingDisabled

2012-04-22 Thread Oliver Heger
Thank you for reporting this. I agree with you that the output of the 
configuration should be independent on the value of the delimiter 
parsing flag.


If you are convinced that this is an error, please open a ticket in our 
bug tracking system [1].


I hope to find some time in the next days to have a look at this issue.

Oliver

[1] http://commons.apache.org/configuration/issue-tracking.html

Am 22.04.2012 13:38, schrieb thc...@gmail.com:

Hi.

Sorry for the code not properly indented (content of DelimiterExample.java).

Here it goes again:

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;

public class DelimiterExample
{
   // Configuration file that will have the
   // setDelimiterParsingDisabled as _false_.
   private static final String CONF_DELIMITER_ENABLED_XML =
 ConfDelimiterEnabled.xml;

   // Configuration file that will have the
   // setDelimiterParsingDisabled as_true_.
   private static final String CONF_DELIMITER_DISABLED_XML =
 ConfDelimiterDisabled.xml;

   // Key of the data used in the configuration files.
   private static final String LIST_ELEMENT_KEY = list.element;

   public static void main(String[] args) throws ConfigurationException
   {
 // Data that will be saved in the configuration files.
 ListString  data = new ArrayListString(3);
 data.add(value 1);
 data.add(value 2);
 data.add(value 3);


 // First using setDelimiterParsingDisabled as false.

 XMLConfiguration confDelimiterEnabledWrite =
   new XMLConfiguration(CONF_DELIMITER_ENABLED_XML);

 confDelimiterEnabledWrite.setProperty(LIST_ELEMENT_KEY, data);
 // Writes:
 //list
 //elementvalue 1/element
 //elementvalue 2/element
 //elementvalue 3/element
 ///list

 confDelimiterEnabledWrite.save();

 XMLConfiguration confDelimiterEnabledRead =
   new XMLConfiguration(CONF_DELIMITER_ENABLED_XML);
 String[] values =
   confDelimiterEnabledRead.getStringArray(LIST_ELEMENT_KEY);

 // Doesn't output anything as they are equals. Expected behaviour.
 if (!Arrays.equals(values, data.toArray()))
 {
   System.out.println(
 setDelimiterParsingDisabled(false): Data not equal!);
 }


 // Now using setDelimiterParsingDisabled as true.

 XMLConfiguration confDelimiterDisabledWrite = new XMLConfiguration();
 confDelimiterDisabledWrite.setDelimiterParsingDisabled(true);
 confDelimiterDisabledWrite.setFileName(CONF_DELIMITER_DISABLED_XML);
 confDelimiterDisabledWrite.load();

 confDelimiterDisabledWrite.setProperty(LIST_ELEMENT_KEY, data);
 // Writes:
 //list
 //element[value 1, value 2, value 3]/element
 ///list

 // Unexpected behaviour!
 // Shouldn't it write the same as with
 // setDelimiterParsingDisabled as false? as it is a list.

 confDelimiterDisabledWrite.save();

 XMLConfiguration confDelimiterDisabledRead = new XMLConfiguration();
 confDelimiterDisabledRead.setDelimiterParsingDisabled(true);
 confDelimiterDisabledRead.setFileName(CONF_DELIMITER_DISABLED_XML);
 confDelimiterDisabledRead.load();

 values = confDelimiterDisabledRead.getStringArray(LIST_ELEMENT_KEY);

 // As it writes other thing this will output that they are not equals.
 if (!Arrays.equals(values, data.toArray()))
 {
   System.out.println(
 setDelimiterParsingDisabled(true): Data not equal!);
 }
   }

}


Best regards.




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] recursive inclusion of xml files with fileNames tag

2012-04-20 Thread Oliver Heger

Hi Oliver,

Am 20.04.2012 08:59, schrieb Oliver Zemann:

Hi Oliver ;)
Thanks for your help.

I tried it with the following code/config:

public static void main(String[] args) {
 CombinedConfiguration conf = null;
 try {
 DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder(new File(conf/conf.xml));

 conf = builder.getConfiguration(true);
 } catch (Exception ex) {
 ex.printStackTrace();
 }
 IteratorString  keys = conf.getKeys();
 }

conf.xml:
?xml version=1.0 encoding=UTF-8?
configuration

 configuration fileName=conf1.xml /
 configuration fileName=conf2.xml /
 configuration fileName=conf3.xml /

/configuration

conf1.xml:
?xml version=1.0 encoding=UTF-8?
conf1
 nameconf1/name
 xml fileName=conf1extend.xml /
/conf1

conf1extend.xml:
?xml version=1.0 encoding=UTF-8?
ext
 nameextended/name
/ext

but i get:
Caused by: org.apache.commons.configuration.ConfigurationRuntimeException:
No ConfigurationProvider registered for tag name
at 
org.apache.commons.configuration.DefaultConfigurationBuilder$ConfigurationBeanFactory.createBean(DefaultConfigurationBuilder.java:1293)
at 
org.apache.commons.configuration.beanutils.BeanHelper.createBean(BeanHelper.java:336)
... 14 more

Its a simple string so i am sure this should work out of the box,
shouldnt it? I did not find any parameter like datatype which i
could pass to the config element.


The problem is the name element. The XML file included by the 
configuration element can only contain elements declaring other 
configuration sources like xml or properties. (It must conform to 
the same format as supported by DefaultConfigurationBuilder.) If you 
want to give the included configuration a name, use this syntax:


configuration
  xml fileName=conf1extend.xml config-name=conf1 /
/configuration

Oliver



Thanks for your help.

Oli

Am 19. April 2012 22:09 schrieb Oliver Hegeroliver.he...@oliver-heger.de:

Hi Oliver,

Am 19.04.2012 16:05, schrieb Oliver Zemann:


Hi,

just a short question:
is it possible to include recursive all xml files that are referenced
by any already included xml?
eg.:

root.xml:
?xml version=1.0 encoding=UTF-8?
additional
 xml fileName=other.xml config-name=another/
/additional

other.xml:
?xml version=1.0 encoding=UTF-8?
  xml fileName=other1.xml config-name=another1/
xml fileName=other2.xml config-name=another2/
...

?

I tried it but they are simply ignored. Only the first recursion level
(other.xml) is handled, all elements in other1.xml other2.xml ... are
ignored.
Can i somewhere put a recursive flag to the configuration?
Thanks.



IIUC, theconfiguration  element is the one you are looking for. You can
use it in a configuration definition file processed by
DefaultConfigurationBuilder to include another definition file. This works
recursively.

So rather than usingxml  tags to include files, make use of
configuration  elements. More details can be found in the user's guide [1].

Oliver

[1]
http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] recursive inclusion of xml files with fileNames tag

2012-04-19 Thread Oliver Heger

Hi Oliver,

Am 19.04.2012 16:05, schrieb Oliver Zemann:

Hi,

just a short question:
is it possible to include recursive all xml files that are referenced
by any already included xml?
eg.:

root.xml:
?xml version=1.0 encoding=UTF-8?
additional
 xml fileName=other.xml config-name=another/
/additional

other.xml:
?xml version=1.0 encoding=UTF-8?
  xml fileName=other1.xml config-name=another1/
xml fileName=other2.xml config-name=another2/
...

?

I tried it but they are simply ignored. Only the first recursion level
(other.xml) is handled, all elements in other1.xml other2.xml ... are
ignored.
Can i somewhere put a recursive flag to the configuration?
Thanks.


IIUC, the configuration element is the one you are looking for. You 
can use it in a configuration definition file processed by 
DefaultConfigurationBuilder to include another definition file. This 
works recursively.


So rather than using xml tags to include files, make use of 
configuration elements. More details can be found in the user's guide [1].


Oliver

[1] 
http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Configuration_definition_file_reference




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: synchronization and XMLPropertiesConfiguration

2012-04-18 Thread Oliver Heger

Hi Julien,

Am 18.04.2012 09:10, schrieb Julien Wajsberg:

Hi,

I've a question about XMLPropertiesConfiguration in commons-configuration.

It's said in the Java Doc that Configuration objects of this type can
be read concurrently by multiple threads. However if one of these
threads modifies the object, synchronization has to be performed
manually. I'd like to know more, especially about what should be
synchronized.

As I understand it, modifying the object means changing one of its
core values, like the file to load from/save to, the encoding, etc. It
doesn't mean adding or setting a property. Is that true ?


No, the configuration's properties are also affected. Internally, they 
are stored in node-like structures which are not synchronized against 
concurrent access. Therefore concurrent modifications can have 
unexpected results.




Also, if manual synchronizing is needed (because we change one of
these values), should it be done on the reloadLock returned by
getReloadLock, and then we'd not have to synchronize manually on
loading/saving/setting ?


Yes, the reloadLock is a good option because it is already used by some 
internal methods of the library.


HTH
Oliver



Thanks,



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: synchronization and XMLPropertiesConfiguration

2012-04-18 Thread Oliver Heger

Am 18.04.2012 23:35, schrieb Julien Wajsberg:

Hi Olivier,

On 18 April 2012 21:40, Oliver Hegeroliver.he...@oliver-heger.de  wrote:


As I understand it, modifying the object means changing one of its
core values, like the file to load from/save to, the encoding, etc. It
doesn't mean adding or setting a property. Is that true ?



No, the configuration's properties are also affected. Internally, they are
stored in node-like structures which are not synchronized against concurrent
access. Therefore concurrent modifications can have unexpected results.


However, it seems like setProperty is synchronized with the reloadLock as well ?
(see 
http://grepcode.com/file/repo1.maven.org/maven2/commons-configuration/commons-configuration/1.8/org/apache/commons/configuration/AbstractFileConfiguration.java#AbstractFileConfiguration.setProperty%28java.lang.String%2Cjava.lang.Object%29)

Am I missing something ?

You are right.

Originally access to properties was not thread-safe. Later on changes 
have been made to support concurrent access, so my information is not 
up-to-date.


However, I was not the author, and I am not sure whether really all 
access paths are synchronized.


Oliver



Thanks



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] PropertyConverter.to method fails

2012-03-24 Thread Oliver Heger

Am 19.03.2012 10:45, schrieb GMail Manzoni.Alessandro4:

il 17.03.2012 18:05, Scrive Oliver Heger 124499136:

You are right, this is a bug in PropertyConverter.to(). The trivial or
identity conversion should be handled, too. I opened a bug ticket to
track this:
https://issues.apache.org/jira/browse/CONFIGURATION-487

Thanks for the report!
Oliver

[...]
When 1.9 will be available?
Download link still refers to 1.8.


1.9 is currently under development. There is no concrete release date 
yet. (We do not have regular release cycles.)


Oliver



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Enum constants as keys

2012-03-24 Thread Oliver Heger

Hi Chris,

this is certainly interesting stuff. Now that Commons Configuration 
requires Java 1.5 at minimum, we are able to define an API which makes 
use of enum constants.


Especially the aspect of annotation meta data seems promising IMHO. 
There are surely many good use cases.


What I am not sure about is how to actually integrate this new feature 
with the existing API. I think we should not enforce the use of enums in 
general. Some applications may require generating keys dynamically; 
also, HierarchicalConfiguration supports complex keys allowing the 
selection of specific elements in hierarchical structures.


So should there be overloaded methods for both plain String keys and 
enum keys? This would bloat the API. Would there be two different 
Configuration interfaces?


Oliver

Am 21.03.2012 18:44, schrieb Christof May:

Hi all,

I'm not sure if this issue has been discussed before (couldn't find
anything on the mail list thou...), but what do you guys think of using
type-safe enum constants as keys instead of plain String values?

I assume there is a general understanding here that using enum constants
instead of strings is the right thing to do, but obviously there are
also important reasons not do so (legacy code, interface changes,
pre-Java1.5 stuff etc...). But I guess the most important one is that
Java enums never have been designed to work in a generic form (namely:
no abstract enums and/or enum inheritance). So there is no way to put an
enum placeholder in a library, and provide the concrete enum values in
the implementing application. An issue which I and other people already
have bemoaned (see
http://java.dzone.com/articles/java-should-have-extended for example),
but it is nevertheless a given fact we have to live with in the
foreseeable future... :(

Having said that, I just see two ways of using enum constants for
fetching config values. For one just using a lame
config.getWhatever(MyEnum.key.name()) everywhere. It would be a start,
but well.. not really what I was searching for...

The other solution I see would be to mark the enums with a marker
interface, and take that as the key placeholder, such as:

public interface Configurable {
public String name();
}

public interface Configuration {
boolean getBoolean(Configurable key);
(other methods follow here...)
}

In the application you would define the keys in an enum such as that:

public enum MyKeys implements Configurable {
FOO,
BAR,
...;
}

Then you could access the config values in real type-safe way:

boolean myValue = config.getBoolean(MyKeys.BAR);

Another advantage would be that enum constants can be easily enriched
with meta-data (via a custom annotation), for example:

public enum MyKeys implements Configurable {
@ConfigData(
defaultValue=foo,
type=String.class,
mandatory=true,
pattern=[a-z]{1,4},
reload=false)
FOO,
...;
}

The possibilities here are endless (see also my pet project at
www.soplets.org exploring more in-depth the meta-data aspects of
annotations), but for a beginning having just enum constants alone would
be a good start in my view...

What do you think about that proposal, does that make any sense? Any
other options I have overlooked so far? Looking forward hearing your
opinions...

regards,

Chris May



















-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] PropertyConverter.to method fails

2012-03-17 Thread Oliver Heger

Am 16.03.2012 18:42, schrieb GMail - Ugo Gagliardelli:

I'm experiencing a problem while reading an ini file.
My class is mapping ini section values to comfortable values such as
Integer, InetAddress and so on, when I retrieve a value as a String I
get a ConversionException. This is tha stack trace:


My code act as:
DataConfiguration db = new
DataConfiguration(getConfig().getSection(sectionName));
where getConfig returns a HierarchicalINIConfiguration object

Object value = db.get(keyType, keyName));

where keyType is a Class? object and keyName is a String object

When keyType is java.lang.String I have the problem.
Inside PropertyConverter.to(Class? cls, Object value, Object[] params)
there is a long if/else that if argument cls is java.langString doesn't
match any condition and throws a ConversionException.

Is this figure correct?

Maybe at the very beginning of the to method should be:

if (cls == value.getClass()) return value;
Thank you for the attention


You are right, this is a bug in PropertyConverter.to(). The trivial or 
identity conversion should be handled, too. I opened a bug ticket to 
track this:

https://issues.apache.org/jira/browse/CONFIGURATION-487

Thanks for the report!
Oliver



Ugo Gagliardelli

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] How to get threadsafe subset() config in a threadsafe way?

2012-03-14 Thread Oliver Heger

Am 13.03.2012 19:05, schrieb Tim Bessie:

That's a possibility which I'll look into.

In the meantime, after initializing our main Configuration wrapper object
with all of our static configuration data, I copy slices of it to static
maps that I know will never change, and provide convenience accessors to
those maps' data.  Since the calls that access the data placed in these new
maps were the only ones asking for slices of config data, this eliminates
our problem.  I was just hoping for a more elegant solution.  But at least
this way there's no locks necessary.

I'll take a look at your suggestions, however - thanks much!

A nice feature in the future could be something like
ConfigurationUtils.getSynchronizedInstance(Configuration), for example.
  I'm sure it's been discussed before. :-)

- Tim


You are right, support for concurrent access to Configuration objects 
can certainly be improved.


Can you provide a stack trace of such a ConcurrentModificationException 
you receive occasionally?


Thanks
Oliver



On Tue, Mar 13, 2012 at 1:43 AM, Luc Maisonobeluc.maison...@free.frwrote:


Le 13/03/2012 07:34, Tim Bessie a écrit :

Hi all...


Hi Tim,



So we're keeping some config information CompositeConfiguration object,

and

we need to get subsets of this configuration data.

When I call .subset(...), and then do some checks on the subset

(isEmpty(),

etc.), I sometimes get ConcurrentModificationExceptions.  I'm not sure
what's modifying the underlying configuration, although we do have
occasional setting of configuration values throughout the running of our
app.

What would be *ideal* would be to:

1. NOT have to synchronize every access to the configuration object,

since

we have a high-volume application
2. To allow read and write operations to happen to the configuration

object

without worrying about ConcurrentModificationExceptions
3. To be able to call .subset(...) on the configuration object and 1) not
risk a ConcurrentModificationException during this operation, and 2) get

a

COPY of the subset back, so that further operations on the subset don't
risk ConcurrentModificationExceptions

Does anyone know of a way to do this?  Or is the ONLY way to guarantee

lack

of CMEs to synchronize EVERY access (reads, writes, subsets, iterations,
etc.)?


Perhaps you could try java.util.concurrent.locks.ReadWriteLock ? You
would have to put the protection by yourself so it may require lots of
code wrapping. One of the good thins is that it allows concurrent read
(but when a write occurs, only one thread can write and reads are blocked).

Luc



If this is the case, how have others dealt with situations like ours,

where

you do mostly just reads on a Configuration object, but very occasional
writes, and need to take subsets, and need to avoid exceptions while

doing

this?  With a high volume app, synchronizing every access would slow

things

waay down, thus my question.

- Tim




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org








-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] Variable interpolation across files broken

2012-02-26 Thread Oliver Heger

Am 26.02.2012 09:19, schrieb sam iam:





Hi, With Commons Configuration 1.6, I was able to declare a variable in a properties 
file, and then reference it in a XML file using the ${myvar} syntax. For example: 
global.properties-myvar=abc test.xml-products
   product name=abc
 desc${myvar}-product/desc
   /link/product  config.xml-properties fileName=global.properties/xml 
fileName=test.xml config-name=test validating=true
   expressionEngine 
config-class=org.apache.commons.configuration.tree.xpath.XPathExpressionEngine/
   reloadingStrategy refreshDelay=5000 
config-class=org.apache.commons.configuration.reloading.FileChangedReloadingStrategy/
/xml
When I try to retrieve the value, like so: 
combinedConfig.getConfiguration(test).configurationAt(products/product[@name='abc'], 
true).getString(desc) I get ${myvar}-product instead of abc-product. This was working in 
Commons Configuration 1.6, but seems to be broken in 1.7 and 1.8. Did something change, or is there a different way to do this? 
Or is this a bug?  


This seems to be a regression between versions 1.6 and 1.7. Could you 
please open a ticket in our bug tracking system [1]? Please attach your 
test configuration files so we can reproduce the problem.


Thanks!
Oliver

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCEMENT] Commons Configuration 1.8 Released

2012-02-05 Thread Oliver Heger

The Apache Commons team is pleased to announce the availability
of Commons Configuration 1.8.

The Commons Configuration software library provides a generic 
configuration interface which enables an application to read 
configuration data from a variety of sources, e.g. properties files, XML 
documents, JDBC datasources and many more. More information can be found 
at the Configuration main site at

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

The focus of the new release lies in adding support for Java 1.5. This 
is now the minimum required JDK version. The API has been slightly 
adapted to new language features. This could be achieved in a binary 
compatible way; thus Commons Configuration 1.8 is a drop-in replacement 
for Commons Configuration 1.7. In addition, a few bugs have been fixed.


A full list of changes since the previous release can be found in the 
release notes or in the changes report at

http://commons.apache.org/configuration/changes-report.html

Apache Commons Configuration is available in either binary or source 
form from the Configuration downloads page:

http://commons.apache.org/configuration/download_configuration.cgi

(Please remember to verify the provided checksums and/or signatures 
after you have downloaded a distribution!)


Oliver Heger
on behalf of the Apache Commons Team


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] XPathExpressionEngine - xpath syntax

2011-12-29 Thread Oliver Heger

Hi, some comments below...

Oliver

Am 29.12.2011 11:02, schrieb M M:

Hi, I'm trying to use /_*Commons Configuration*_/ to parse an XML
configuration file and I'm having some troubles with the xpath syntax.
After a few tries I understood that I need to use the
XPathExpressionEngine, and i think that the problems I'm facing are due
to the xpath syntax I'm using.

Here is the xml file:

general-configuration
permissions
allowed-projects
project id=10020 key=TP1test project 1/project
project id=10021 key=TP2test project 2/project
project id=10022 key=TP3test project 3/project
/allowed-projects

allowed-groups
group id=xyz name=test group/
/allowed-groups

allowed-users
user id=zxy name=test user/
/allowed-users
/permissions

kpi-definition
project id=10020 key=DP
issue-type id=1 name=Bug
kpi id=1 name=t0 - t1 days=0 hours=0 minutes=10
transition id=1 name=a1/transition
transition id=2 name=b2/transition
/kpi
kpi id=2 name=t1 - t2 days=0 hours=1 minutes=0
transition id=3 name=c1/transition
transition id=4 name=d2/transition
/kpi
/issue-type

issue-type id=3 name=Task

kpi id=1 name=t0 - t1 days=0 hours=0 minutes=10
transition id=5 name=e/transition
transition id=6 name=f/transition
/kpi

kpi id=2 name=t1 - t2 days=0 hours=1 minutes=0
transition id=7 name=g/transition
transition id=8 name=h/transition
/kpi
/issue-type
/project
/kpi-definition
/general-configuration


And here is the code I wrote to try to understand how to get what i want
using the XPathExpressionEngine

private XMLConfiguration configurationFile;

configurationFile = new XMLConfiguration(/kpi_configuration.xml/);
configurationFile.setExpressionEngine(new XPathExpressionEngine());


DefaultExpressionEngine defaultEngine = new DefaultExpressionEngine();
defaultEngine.setPropertyDelimiter(///);
configurationFile.setExpressionEngine(defaultEngine);

*// using the default expression engine i get what i want, a list of the
// id attributes of the project tag (10020,10021,10022)*
ListString testList001 =
configurationFile.getList(/permissions/allowed-projects/project[@id]/);
for (IteratorString iterator = testList001.iterator();
iterator.hasNext();)
{
System.out.println(iterator.next());
}

configurationFile.setExpressionEngine(new XPathExpressionEngine());
*// using the xpath expression engine, and giving exactly the same path
to the getList method
// i get a completely different result! the list is made of the text
content of the tag
// (test project 1, test project 2, test project 3)*
ListString testList002 =
configurationFile.getList(/permissions/allowed-projects/project[@id]/);
for (IteratorString iterator = testList002.iterator();
iterator.hasNext();)
{
System.out.println(iterator.next());
}


Try the key permissions/allowed-projects/project/@id; the square 
brackets are not needed for accessing attributes.




*// here I tried to use the xpath syntax [@attribute=value] to get into
a specific branch of the xml tree
// the expected result was at least a list of values, instead i get null
object*
ListString testList003 =
configurationFile.getList(/kpi-definition/project[@id=10020]/issue-type[@id=1]/transition/);

for (IteratorString iterator = testList003.iterator();
iterator.hasNext();)
{
System.out.println(iterator.next());
}


For this and the following example it may be necessary to quote the 
values because they are strings, e.g.

kpi-definition/project[@id='10020']/issue-type[@id='1']/transition



*// here I tried to use the xpath syntax [@attribute=value] to get into
a specific branch of the xml tree
// the expected result was a single value instead i got a null object*
String testValue001 =
configurationFile.getString(/kpi-definition/project[@id=10020]/issue-type[@id=1]/transition[@name=a]/);

System.out.println(testValue001);

Many, many thanks in advance to everyone who can help me!
I really can't work it out (... and I have to :) ... )
MM





-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



  1   2   >