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]