Reputation: 2047
I am trying to get my head around using the org.osgi.service.cm.ManagedService and Configuration Admin for Apache Felix.
I understand that the ConfigurationAdmin pushes new configurations to the service via the method
public void updated(Dictionary<String, ?> dctnr) throws ConfigurationException
But i have a few questions:
The method signature seems to suggest that i can persist any configuration item in the Configuration, given the Dictionary<String, ?>
. Is this the case, or is it only String values that you can use for configuration values? I have yet to find an example that uses anything but Strings.
Given that you can persist Objects as configuration values, what conventions must i follow in order for the Configuration Admin to actually persist them? Must they be Java Beans, or Serializable or JaxB enabled or maybe something else entirely?
Can i somehow get some information out of the Configuration Admin describing the type of the Object that is returned for a particular key? Say that i put a Date in one key, and a String in another, does the application just have to retain this knowledge, or can I get the information from the ManagedService somehow?
Upvotes: 0
Views: 366
Reputation: 2359
The configuration object is defined in the Configuration Admin spec (see OSGi Compendium Release 5 Specification) as a dictionary of properties. Property values are referred to as the primary property types as defined in the Core spec.
This is the definition of primary property types in OSGi Core Release 5 Specification:
type ::= scalar | collection | array
scalar ::= String | Integer | Long | Float | Double | Byte | Short | Character | Boolean
primitive ::= int | long | float | double | byte | short | char | boolean
array ::= <Array of primitive> | <Array of scalar>
collection ::= <Collection of scalar>
Upvotes: 1