Hi Clement,
Have been testing the Configuration Admin functionality of a simple
iPOJO component that implements an EventAdmin EventHandler service and
updates the event.topics property associated with the service in
response to Configuration Admin change. In other words it's an
eventHandler that consumes different events from different publishers
based on configuration changes received from Configuration Admin.
Here is the metadata of the iPOJO component:
<iPOJO>
<component
className="com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler"
name="com.verticon.experiment.ipojo.configuration" architecture="true">
<Provides
interface="org.osgi.service.event.EventHandler">
<DynamicProperty
name="event.topics"
field="topics"
value="com/verticon/rfid/MOVEMENT"/>
</Provides>
<ConfigurableProperty
field="topics" name="event.topics" />
<callback
final="VALID" initial="INVALID" method="starting"/>
<callback
final="INVALID" initial="VALID" method="stopping"/>
</component>
</iPOJO>
1. The first issue (problem?) that I see is that the iPOJO container
(org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler)
registers, unregisters, and registers a second time as a ManagedService
with the framework. Note the ConfiguationAdmin
(org.apache.configuration.impl) implementation uses a separate thread
for callbacks to invoke the updated method on the service.
The following is log output of the start of a bundle containing the
above iPOJO component. You can see the multiple binds and the unbinds
the underlying servicebinder is making on the ConfigurationAdminFactory.
-> start 23
INFO [Felix Shell TUI]
org.apache.configuration.impl.ConfigurationAdminFactory.setManagedService(ConfigurationAdminFactory.java:141)
- Binding to ManagedService [EMAIL PROTECTED]
(com.verticon.experiment.ipojo.configuration) from
file:bundle/ipojo.configuration-1.0-SNAPSHOT.jar
DEBUG [Felix Shell TUI]
com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler.<init>(ConfiguribleEventHandler.java:17)
- Constructed
DEBUG [Felix Shell TUI]
com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler.starting(ConfiguribleEventHandler.java:21)
- Starting
INFO [Felix Shell TUI]
org.apache.configuration.impl.ConfigurationAdminFactory.unsetManagedService(ConfigurationAdminFactory.java:157)
- Unbinding from ManagedService [EMAIL PROTECTED]
(com.verticon.experiment.ipojo.configuration) from
file:bundle/ipojo.configuration-1.0-SNAPSHOT.jar
ERROR [Update Consumer]
org.apache.configuration.impl.UpdateConsumer.handleEvent
(UpdateConsumer.java:155) - Failed to handle a ServiceRegistration
event.
java.io.IOException: Could not find a bundle from the serviceReference
[org.osgi.service.cm.ManagedService]
at
org.apache.configuration.impl.UpdateConsumer.addLocationToPidsAndCheck
(UpdateConsumer.java:480)
at org.apache.configuration.impl.UpdateConsumer.handleEvent
(UpdateConsumer.java:130)
at org.apache.configuration.impl.UpdateConsumer.run
(UpdateConsumer.java:97)
at java.lang.Thread.run(Thread.java:595)
INFO [Felix Shell TUI]
org.apache.configuration.impl.ConfigurationAdminFactory.setManagedService(ConfigurationAdminFactory.java:141)
- Binding to ManagedService [EMAIL PROTECTED]
(com.verticon.experiment.ipojo.configuration) from
file:bundle/ipojo.configuration-1.0-SNAPSHOT.jar
2. The second issue I have seen is that the container
(ConfigurationHandler) is rejecting all configuration properties.
(Would have expected at least that the event.topics would be accepted
and propagated as it is specified in the metadata. Or did I setup the
metadata wrong?)
Don't think the container can be so picky with the configs. As specified
in the OSGi Compendium Spec R4 p 70-432 All Configuration Properties
should be accepted and propagated to the service registration by the
ManagedService (in this case the iPOJO container). Here is a log output:
INFO [Update Consumer]
org.apache.configuration.impl.UpdateConsumer.updateManagedService
(UpdateConsumer.java:245) - Invoking updated on
[EMAIL PROTECTED], with
configuration=org.apache.configuration.impl.ConfigurationDictionary [
event.topics=com/verticon/rfid,
service.pid=com.verticon.experiment.ipojo.configuration,
objectclass=[react2Server, apacheServiceConfiguration, top], cn=ipojo ]
Jun 8, 2006 3:39:02 PM
org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler
updated
SEVERE:
[com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler]
The configuration is not valid, the field event.topics is not a
configurable property
Jun 8, 2006 3:39:02 PM
org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler
updated
SEVERE:
[com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler]
The configuration is not valid, the field service.pid is not a
configurable property
Jun 8, 2006 3:39:02 PM
org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler
updated
SEVERE:
[com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler]
The configuration is not valid, the field objectclass is not a
configurable property
Jun 8, 2006 3:39:02 PM
org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler
updated
SEVERE:
[com.verticon.experiment.ipojo.configuration.ConfiguribleEventHandler]
The configuration is not valid, the field cn is not a configurable
property
kind regards,
John