I should note that you can, pretty easily, create a translation that would take 
the XML below - from a file or whatever - parse it and turn it into the 
dictionary using any of the discussed encoding.   The "end user" would see only 
the perfect XML encoding.  The consumer - i.e. the service implementing the 
ManagedService interface - which actually uses the dictionary doesn't, or 
really shouldn't, care about prettiness.  Rather all they have to do is get the 
data and know how to do it.

On Feb 6, 2010, at 8:18 AM, Hal Hildebrand wrote:

> Why don't you just put your XML string as the value in the config admin?
> 
> If you really _have_ to do it "right", then I would use the host name as the 
> key, and the port as the value.  But this assumes all the host names are 
> unique, which they might not well be.  But using XML documents as the values 
> in config admin dictionaries is just as "elegant" as anything else.  Even 
> your approach below is perfectly acceptable and, imho, not be considered "sub 
> optimal".
> 
> I haven't tried it myself, but I believe the ConfigAdmin should already work 
> with the MetaType service.  But, as I said, I have not done such as I don't 
> find the work arounds such as discussed above unacceptable...
> 
> On Feb 6, 2010, at 2:52 AM, Daniel Bimschas wrote:
> 
>> Hi list!
>> 
>> I'm writing an application that uses Configuration Admin to be configured at 
>> runtime. Now, for one of my DS components I have a more complex 
>> configuration requirement. Assume e.g. I want to configure the component to 
>> create a set of TCP connections. Using XML configuration I would use 
>> something like this snippet:
>> 
>> <connections>
>>   <connection>
>>     <host>somehost.com</host>
>>     <port>1234</port>
>>   </connection>
>>   <connection>
>>     <host>someotherhost.com</host>
>>     <port>4321</port>
>>   </connection>
>> </connections>
>> 
>> My question now is if there's an elegant way to map such a set of complex 
>> configuration objects to Configuration Admins properties file format? Maybe 
>> I don't see the wood for the trees but I can't think of a nice way (so that 
>> I could also use the Metatype Service specification), except this suboptimal 
>> one:
>> 
>> connection.host = {somehost.com,someotherhost.com}
>> connection.port = {1234,4321}
>> 
>> where each entry of the string array of the property 'connection.host' key 
>> must have an according entry 'connection.port' with the same index. However, 
>> that solution will make editing the configuration files very error prone and 
>> unintuitive.
>> 
>> I can think of another alternative, which is using a component factory that 
>> creates one instance of my service per connection configuration. But I have 
>> other use cases for which this approach would not be feasible.
>> 
>> If there's no elegant way my next question is the following: are there any 
>> activities towards an XML based counterpart to Configuration Admin Service 
>> and Metatype Service?
>> 
>> 
>> Kind regards,
>> Daniel Bimschas
>> _______________________________________________
>> OSGi Developer Mail List
>> [email protected]
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
> 


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to