It sounds like you have a Managed Service Factory, with an instance
for each connection ... This allows you easily to add and remove
connections on the fly. So would have two properties: host, port.
In FileInstall (see http://felix.apache.org/site/apache-felix-file-install.html)
you would add two files to the file install directory:
com.bimschas.some.connections-somehost.cfg:
host: somehost.com
port: 1234
com.bimschas.some.connections-someotherhost.cfg:
host: someotherhost.com
port: 4321
I do not think Metatype helps you here. Metatypes only provide
configuration types so you can edit it easier. There are no plans for
XML based configuration because Config Admin can actually handle the
kind of schemes you want, as you can see. The advantage of Config
Admin is that it is trivially to add and remove entries; a big XML
file has the problem that this kind of small-granularity editing is
much more disruptive because you have to update the whole file and
therefore all its targets.
That said, if you like XML, it is not that hard to take an XML file
and convert it to a set of configuration objects.
Kind regards,
Peter Kriens
On 6 feb 2010, at 11:52, 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