Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E4BDF8704 for ; Wed, 7 Sep 2011 18:06:21 +0000 (UTC) Received: (qmail 49154 invoked by uid 500); 7 Sep 2011 18:06:20 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 49010 invoked by uid 500); 7 Sep 2011 18:06:20 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 49000 invoked by uid 99); 7 Sep 2011 18:06:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 18:06:19 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.17.10] (HELO moutng.kundenserver.de) (212.227.17.10) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 18:06:13 +0000 Received: from [192.168.0.101] (ip-109-90-80-138.unitymediagroup.de [109.90.80.138]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Mhgu7-1QnO7Y2POl-00MNg5; Wed, 07 Sep 2011 20:05:51 +0200 Message-ID: <4E67B27A.1040008@oliver-heger.de> Date: Wed, 07 Sep 2011 20:05:46 +0200 From: Oliver Heger User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 MIME-Version: 1.0 To: Commons Users List Subject: Re: configuration --- get the properties object loaded after the delayed refresh References: <1315028886.931.YahooMailNeo@web36903.mail.mud.yahoo.com> <1315029561.96493.YahooMailNeo@web36905.mail.mud.yahoo.com> <4E62505E.9070203@oliver-heger.de> <1315414994.73456.YahooMailNeo@web36907.mail.mud.yahoo.com> In-Reply-To: <1315414994.73456.YahooMailNeo@web36907.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:MkiDc2AxutweREAb7E6xAx56vpcHwEuK3HNEHzI7Nie W+/R3NmRNoE+X8evttnxPG2PUGYsa+/HWawC6Hb5BrMsUp9QNw 8FUvel6K+vo2Pjf5YSVdcAPquSDVliEd8s8rMjhRO5bR1vqPF8 WIUCS8FJ8rJYmXhknuWi2E2SnqTdcfr1m2GcdR7E750RLF3lao jngS2liTOP2Qc+oBGZm7FIrYapY9rGhwayjt9vtBWZUr6Pp3UV W917njBd1Z9Lg8zpyWJ/SfJ0RVE6inDiQu/FsLa2koCFButJ9u 753wZSxvpiQsp5rITif7LXE15BhQ7R3BaHN3rKSm8g/zb5tWPU PxR/TG7kRV9YppIMdgCI= Am 07.09.2011 19:03, schrieb Srinivas Jonnalagadda: > Oliver, > > Thanks for the reply. I wrote a JUNIT test and Below is the code. My aim was that when i set the refresh delay to 500 and after the initial test passed i put a thread.sleep for 2 minutes. when the thread sleeps i am changing the value of the JEDI_ENVIRONMENT to some thing else. When the thread wakes up I wanted to see the props refreshed with new values so that the tes tcase fails which means the program runs as expected. Pls help me. > Hi Srinivas, somehow your code got mangled, so it is hardly readable. But if I understand correctly, you obtain a Properties object from the configuration using something like Properties props = ConfigurationConverter.getProperties(config); Then you expect that the properties are automatically refreshed by the reloading strategy without any further action from your side, correct? Well, the reloading strategies do not work that way unfortunately. Currently, there is no implementation which actively monitors a configuration file. Rather, the reloading strategy is only triggered when the configuration object is accessed, e.g. if a property is queried. FileChangedReloadingStrategy then checks the timestamp of the configuration file. If it has changed, it reloads the configuration. So you will only see new values if you query the configuration again. HTH Oliver > > sincerely, > Srinivas Jonnalagadda > @TestPropertiesConfiguration config = > Properties props = > config.setFileName( > config.load(); > FileChangedReloadingStrategy strategy = > strategy.setRefreshDelay(500); > config.setReloadingStrategy(strategy); > assertEquals(config.getString( > props = ConfigurationConverter.getProperties(config); > assertEquals(props.getProperty( > Thread.sleep(200000); > assertEquals(config.getString( > System. > assertEquals(props.getProperty( > } > > publicvoidtestGetBuiltPropertyFileName() throwsException {newPropertiesConfiguration(); null;TEST_FILE); newFileChangedReloadingStrategy(); "JEDI_ENVIRONMENT"),"TEST");"JEDI_ENVIRONMENT"),"TEST");"JEDI_ENVIRONMENT"),"TEST");out.println("Test");"JEDI_ENVIRONMENT"),"TEST"); > > From: Oliver Heger > To: Commons Users List > Sent: Saturday, September 3, 2011 11:05 AM > Subject: Re: configuration --- get the properties object loaded after the delayed refresh > > Hi, > > Am 03.09.2011 07:59, schrieb Srinivas Jonnalagadda: >> Hi, >> >> Below is the code for i wrote and seems at the propsConfig object gets refreshd after the delay but the result object has the old values still. How do i get the new values into the result object after the refresh. I am trying to create a Configuration listener as well and that alos seems not to work. The main objective for me is to get the properties object loaded with new values without JBOSS server restart. Any help is appreciated. >> >> >> Regards, >> Srinivas J > > your code looks good, therefore I am not sure whether I fully understand > your problem. > > How can you tell that the properties configuration object is refreshed > correctly when the result object still has the old values? Do you get > other results if you access the configuration object directly, e.g. by > calling propsConfig.getString("someKey") ? (If so, this would indicate a > bug in the ConfigurationConverter.getProperties() implementation.) > > Oliver > >> >> Properties result = null; >> Configuration config = null; >> URL resourceURL = null; >> FileChangedReloadingStrategy refreshStrategy = new FileChangedReloadingStrategy(); >> refreshStrategy.setRefreshDelay(refreshDelay); >> >> PropertiesConfiguration propsConfig = new PropertiesConfiguration(); >> propsConfig.setFileName(name); >> propsConfig.load(); >> propsConfig.setReloadingStrategy(refreshStrategy); >> result = ConfigurationConverter.getProperties(propsConfig); > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org