Hi Daniel,
Allow me to answer both your questions at once: I have not found an elegant
way to map collections of complex objects to property files, which is why I
created a custom service that stores jaxb annotated objects for me in a
persistend datastore. My services store and retrieve these objects during
instance creation and finalization. I found it to be the best way to solve
the problem.
Now that I think of it, we can also use the Config Admin to store marshalled
objects in properties...
Anyway, in my opinion this matter is important enough to extend the Metatype
service with a "marshalled objects" type.
Geert Schuring.
--------------------------------------------------
From: "Daniel Bimschas" <[email protected]>
Sent: Saturday, February 06, 2010 2:17 PM
To: <[email protected]>
Subject: Best practice to configure service (factories) with complex objects
Hi list!
I've posted this question on [email protected], too, but as this list
is more active by far I thought I would also give it a try :-).
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
---------------------------------------------------------------------
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]