RE: [configuration] Calling getConfiguration on DefaultConfigurationBuilder more than once permitted

2014-03-22 Thread Martin Gainty

  


> Date: Sat, 22 Mar 2014 22:39:14 +0100
> From: dont_k...@gmx.net
> To: user@commons.apache.org
> Subject: Re: [configuration] Calling getConfiguration on 
> DefaultConfigurationBuilder more than once permitted
> 
> Hi Martin,
> 
> I found a solution which fits my requirements without this ugly 
> behaviour as described before. The trick is to configure the reloading 
> strategy and force the reload checking in "config.xml":
> 
> 
> 
> 
> 
> 
> 
MG>lets find out what forceReloadCheck and what it does
MG>/commons-configuration>grep -r -l forceReloadCheck *.*
.\src\main\java\org\apache\commons\configuration\CombinedConfiguration.java
.\target\classes\org\apache\commons\configuration\CombinedConfiguration.class

MG>forceReloadCheck has NO effect on 
DefaultConfigurationBuilder.getConfiguration()
protected CombinedConfiguration createAdditionalsConfiguration(
CombinedConfiguration resultConfig)
{
CombinedConfiguration addConfig =
 new CombinedConfiguration(new UnionCombiner()); //this will STILL pull 
UNION of entities

addConfig.setDelimiterParsingDisabled(resultConfig
.isDelimiterParsingDisabled());
addConfig.setForceReloadCheck(resultConfig.isForceReloadCheck());
addConfig.setIgnoreReloadExceptions(resultConfig
.isIgnoreReloadExceptions());
return addConfig;
}
MG>if this was chess ..i have just taken your queen
MG>your move..

> 
> 
> That just made my day :)
> 
> Thanks for your effort
> Stefan
> 
> Am 22.03.2014 02:17, schrieb Martin Gainty:
> > 
> >
> >
> >> Date: Fri, 21 Mar 2014 22:45:29 +0100
> >> From: dont_k...@gmx.net
> >> To: user@commons.apache.org
> >> Subject: [configuration] Calling getConfiguration on 
> >> DefaultConfigurationBuilder more than once permitted
> >>
> >> Hi,
> >>
> >> is it permitted to call getConfiguration more than once on the same
> >> instance of DefaultConfigurationBuilder like this:
> >>
> >> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> >> builder.setFile(new File("config.xml"));
> >> Configuration config = builder.getConfiguration(true);
> >> config = builder.getConfiguration(true);
> >> config = builder.getConfiguration(true);
> >> ...
> >>
> >> The config.xml looks like this:
> >> 
> >>
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >>
> >> and the referenced file "test.properties" contains:
> >> a=a
> >> b=b
> >> c=c
> >>
> >> I asked this question, because with the first call of getConfiguration
> >> the "test.properties"-file is read 10 times (once for every
> >> "config-at"), with the second call 20 times, with the third call 30
> >> times and so on. So in the end the program slows down and after 100
> >> calls it needs 200ms to read the properties.
> > 
> > MG>builder.getConfiguration(true) a Union between one DB Table and another 
> > DB Table
> > MG>if you want to 'merge' 2 groups together I suggest using OverrideCombiner
> > MG>ConfigurationNode combine(ConfigurationNode node1, ConfigurationNode 
> > node2)
> > MG> 
> > http://www.docjar.com/html/api/org/apache/commons/configuration/tree/OverrideCombiner.java.html
> >> I'm a little bit confused because my idea was to instantiate
> >> DefaultConfigurationBuilder for performance reasons only once (as a
> >> Singleton) and call getConfiguration subsequently to read "fresh"
> >> properties.
> >>
> >> Thanks
> >> Stefan
> >>
> >>
> >> -
> >> 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] Calling getConfiguration on DefaultConfigurationBuilder more than once permitted

2014-03-22 Thread dont_know

Hi Martin,

I found a solution which fits my requirements without this ugly 
behaviour as described before. The trick is to configure the reloading 
strategy and force the reload checking in "config.xml":




  

  

  
config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>

  
  ...


That just made my day :)

Thanks for your effort
  Stefan

Am 22.03.2014 02:17, schrieb Martin Gainty:
   




Date: Fri, 21 Mar 2014 22:45:29 +0100
From: dont_k...@gmx.net
To: user@commons.apache.org
Subject: [configuration] Calling getConfiguration on 
DefaultConfigurationBuilder more than once permitted

Hi,

is it permitted to call getConfiguration more than once on the same
instance of DefaultConfigurationBuilder like this:

DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
builder.setFile(new File("config.xml"));
Configuration config = builder.getConfiguration(true);
config = builder.getConfiguration(true);
config = builder.getConfiguration(true);
...

The config.xml looks like this:















and the referenced file "test.properties" contains:
a=a
b=b
c=c

I asked this question, because with the first call of getConfiguration
the "test.properties"-file is read 10 times (once for every
"config-at"), with the second call 20 times, with the third call 30
times and so on. So in the end the program slows down and after 100
calls it needs 200ms to read the properties.
  
MG>builder.getConfiguration(true) a Union between one DB Table and another DB Table

MG>if you want to 'merge' 2 groups together I suggest using OverrideCombiner
MG>ConfigurationNode combine(ConfigurationNode node1,  ConfigurationNode 
node2)
MG> 
http://www.docjar.com/html/api/org/apache/commons/configuration/tree/OverrideCombiner.java.html

I'm a little bit confused because my idea was to instantiate
DefaultConfigurationBuilder for performance reasons only once (as a
Singleton) and call getConfiguration subsequently to read "fresh"
properties.

Thanks
Stefan


-
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



[imaging] Image from 2D-array of "double"s?

2014-03-22 Thread Gilles

Hello.

I wish to easily generate an image representing the data stored in
a double[][]. Each array element is a pixel of the resulting image
(the entry at (0, 0) is the bottom-left pixel of the image).

Then, is there some tool to automatically map a selected range of
data values into a palette of colours[1]?


Thanks for your advice,
Gilles

[1] Values outside the range should be mapped to e.g. black, or even
better, made transparent.


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