I had this same problem after I added support for ExprLookup. I found I 
couldn't configuration it with multiple varaibles since Commons Configuration's 
bean utilities didn't support collections. I added that support in commit 
766914. In your example below, if configs is a Collection then both conf 
elements will be added to it.  Take a look at ExprLookup and the internal 
Variables and Variable class. The Variables class extends ArrayList. An example 
configuration is testExpression.xml where you will find

      <lookup config-prefix="expr"
              
config-class="org.apache.commons.configuration.interpol.ExprLookup">
        <variables>
          <variable name="String" 
value="Class:org.apache.commons.lang.StringUtils"/>
          <variable name="MDC" value="Class:org.slf4j.MDC"/>
        </variables>
      </lookup>

Note that this code is in trunk and has not been incorporated into a release 
yet. I apologize as I should have opened a Jira issue when I committed this. I 
will do that asap and make sure the documentation is updated as well.

Ralph

On Jan 23, 2010, at 7:44 AM, Oliver Heger wrote:

> Am 21.01.2010 16:20, schrieb Maxim Ulanovskiy:
>> Thanks Ralph
>> 
>> The idea is to create a custom Configuration named<remote>  which can
>> load/update configuration files using REST service with some params such as
>> ETag, revision etc. as those features are not supported by standard API. You
>> right I've used DefaultConfigurationBuilder to load this file and registered
>> custom ConfigurationProvider to handle<remote>  tag only:
>> 
>> //client
>> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
>> builder.addConfigurationProvider("remote", new
>> RemoteConfigurationProvider());
>> 
>> //internals
>> public class RemoteConfigurationProvider extends ConfigurationProvider {
>> @Override
>>     public Object createBean(Class beanClass, BeanDeclaration data,
>>             Object parameter) throws Exception {
>>             //this code throws exception because a few<conf>  tags defined
>> 
>> data.getNestedBeanDeclarations().get("configs").getNestedBeanDeclarations();
>>             ...
>>     }
>> }
> 
> DefaultConfigurationBuilder uses the standard mechanism for creating beans as 
> described in [1]. This mechanism treats nested XML elements as nested bean 
> declarations and tries to instantiate corresponding objects.
> 
> Can you please provide more information about the exception you get? From 
> looking at the code it seems that multiple sub elements with the same names 
> are supported. So I can't say what is going wrong here.
> 
> Oliver
> 
> [1] 
> http://commons.apache.org/configuration/userguide/howto_beans.html#Declaring_and_Creating_Beans
> 
>> 
>> 2010/1/21 Ralph Goers<[email protected]>
>> 
>>> I'm having trouble figuring out what you are trying to do. Is this the
>>> configuration file you are feeding to DefaultConfigurationBuilder or
>>> something else? The syntax below doesn't seem to match what
>>> DefaultConfigurationBuilder would expect and I'm not sure why you aren't
>>> just using that since as far as I can tell it supports what you are trying
>>> to do without you writing any custom code.
>>> 
>>> Ralph
>>> 
>>> On Jan 21, 2010, at 12:57 AM, Maxim Ulanovskiy wrote:
>>> 
>>>> Hello,
>>>> I need to extend XML configuration definition to have something like:
>>>> 
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <configuration>
>>>>   <additional>
>>>>       <remote server="http://configserver/config/"; refreshDelay="5000">
>>>>           <configs>
>>>>               <conf>testCfg1.cfg</conf>
>>>>               <conf>testCfg2.xml</conf>
>>>>           </configs>
>>>>       </remote>
>>>>   </additional>
>>>> </configuration>
>>>> 
>>>> To parse "remote" element I've defined custom ConfigurationProvider, but
>>> it
>>>> fails because of there are a few<conf>  tags and the framework holds them
>>> as
>>>> NestedBeanDeclarations that should be unique. How can I resolve this
>>> issue?
>>>> 
>>>> --
>>>> Best Regards,
>>>> Maxim
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> 
>>> 
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to