I've run into a couple different issues when I've tried to register a
service (using the bundle context) inside binding method. Is this
support behavior?
The latest case, I'm registering a ManagedServiceFactory inside a
binding method (setAssetFactory). The registration causes the
ConfigAdmin to immediately create components of a type ExampleAsset
(which is the type produced by ExampleAssetFactory which is the service
being sent into the binding method). Most times the thread to create
the component runs first and fails because the component references
aren't completely satisfied. This kinda makes sense as part of having
the component satisfied is that the binding method (setAssetFactory) was
called. I think everything would be fine if I could wait to register
the ManagedServiceFactory until after the binding method has completed.
ExampleAsset references 3 DevicePowerToggle services. When those
services are available the component factory is satisfied and
setAssetFactory is called. Inside this call a ManagedFactoryService is
registered. The component activation fails because the needed services
are satisfied (because still executing setAssetFactory).
INFO 20110825 16:00:20 ID#11 - Asset pid
example.asset.ExampleAssetConfig.da948425-1c2b-497e-b032-fc5c7db19ea1
updated!
INFO 20110825 16:00:20 ID#11 - Creating new ExampleAsset instance
INFO 20110825 16:00:20 ID#6 - [33;X.FactoryDescriptor] ServiceEvent
REGISTERED
INFO 20110825 16:00:20 ID#11 - Factory for [Example Asset] registered
INFO 20110825 16:00:20 ID#6 - [31;X.AssetFactory] ServiceEvent
REGISTERED
INFO 20110825 16:00:20 ID#6 -
[30;org.osgi.service.component.ComponentFactory] ServiceEvent REGISTERED
ERROR 20110825 16:00:20 ID#19 -
[4;org.osgi.service.cm.ConfigurationAdmin]
[org.osgi.service.cm.ManagedServiceFactory,
org.osgi.service.metatype.MetaTypeProvider, id=32, bundle=6]: Unexpected
problem updating Configuration
PID=example.asset.ExampleAssetConfig.da948425-1c2b-497e-b032-fc5c7db19ea
1, factoryPID=example.asset.ExampleAssetConfig,
bundleLocation=file:/home/dhumeniuk/svn/THOSE/target/generic/controller-
app/deploy/bundle/example.asset.jar
Caused by: org.apache.felix.log.LogException:
org.osgi.service.component.ComponentException: Failed activating
component
at
org.apache.felix.scr.impl.manager.ComponentFactoryImpl.newInstance(Compo
nentFactoryImpl.java:120)
at
example.asset.ExampleAssetFactory.create(ExampleAssetFactory.java:66)
at
example.asset.ExampleAssetFactory.create(ExampleAssetFactory.java:1)
at
mil.dod.th.ose.core.impl.asset.AssetDirectoryServiceImpl$AssetConfigurat
ionService.updated(AssetDirectoryServiceImpl.java:900)
at
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdat
e.run(ConfigurationManager.java:1366)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:104)
at java.lang.Thread.run(Thread.java:619)
INFO 20110825 16:00:20 ID#8 - [29;X.pm.DevicePowerToggle]
ServiceEvent REGISTERED
INFO 20110825 16:00:20 ID#8 - [34;X.pm.DevicePowerToggle]
ServiceEvent REGISTERED
INFO 20110825 16:00:20 ID#8 - [35;X.pm.DevicePowerToggle]
ServiceEvent REGISTERED
David Humeniuk
Software Engineer
L-3 Nova Engineering
4393 Digital Way
Mason, Ohio 45040
513-204-7628 (Direct)
513-204-7600 (Main)
513-204-8999 (Main Fax)
www.L-3com.com/Nova