Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[osgi-users] Fwd: Dynamic component behavior

I am having an issue that I just can't figure out where a volatile (dynamic) reference is not updated as better versions become available.

I have a component with 3 different implementations with different rankings:
{com.castortech.iris.emf.irisdb.custom.api.NotificationHelper}={service.id=1872, service.bundleid=189, service.scope=bundle, service.ranking=10, component.name=com.castortech.iris.ba.core.model.provider.impl.NotificationHelperImpl, component.id=1876}
  "Registered by bundle:" com.castortech.iris.ba.core.model.provider_1.0.0.qualifier [189]
  "Bundles using service"
    org.apache.felix.healthcheck.generalchecks_2.0.6 [413]
{com.castortech.iris.emf.irisdb.custom.api.NotificationHelper}={service.id=1873, service.bundleid=141, service.scope=bundle, service.ranking=5, component.name=com.castortech.iris.irisdb.core.model.helper.impl.CoreNotificationHelperImpl, component.id=1227}
  "Registered by bundle:" com.castortech.iris.irisdb.core_1.0.0.qualifier [141]
  "Bundles using service"
    org.apache.felix.healthcheck.generalchecks_2.0.6 [413]
{com.castortech.iris.emf.irisdb.custom.api.NotificationHelper}={service.id=197, service.bundleid=237, service.scope=bundle, service.ranking=1, component.name=com.castortech.iris.emf.irisdb.custom.utils.impl.NullNotificationHelperImpl, component.id=608}
  "Registered by bundle:" com.castortech.iris.emf.irisdb_1.0.0.qualifier [237]
  "Bundles using service"
    com.castortech.iris.emf.irisdb_1.0.0.qualifier [237]
    org.apache.felix.healthcheck.generalchecks_2.0.6 [413]

The one with ranking = 1 is essentially a noop, and is a component with no references of its own. It is intended to be available during an initial system bootstrap, where here notifications are not relevant.

When starting the application without any existing data repository, the bootstrap process will run. With debugging I can see very early in the startup process that the noop instance is activated and later when the bootstrap happens, the referencing component is started, shown here:
{com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents}={service.id=1255, service.bundleid=237, service.scope=bundle, component.name=com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents, component.id=602}
  "Registered by bundle:" com.castortech.iris.emf.irisdb_1.0.0.qualifier [237]
  "Bundles using service"
    com.castortech.iris.emf.irisdb_1.0.0.qualifier [237]

This component gets activated with a reference to our noop instance and the bootstrap process goes through.

Once that completes I can see the other 2 implementations being activated, more than likely since they are part of the health checks monitoring.

Since the reference in the referencing component is dynamic, I would expect that it would have updated itself once one of the other instances were activated, but it didn't
Here is the content:
osgi> scr:info 602
Component Description: com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents
==========================================================================================
Class:         com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents
Bundle:        237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
Enabled:       true
Immediate:     false
Services:      [com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents]
Scope:         singleton
Config PID(s): [com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents], Policy: optional
Base Props:    (0 entries)

Component Configuration Id: 602
-------------------------------
State:        ACTIVE
Service:      1255 [com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents]
    Used by bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
Config Props: (2 entries)
  component.id<Long> = 602
  component.name<String> = com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents
References:   (total 19)
  - baTypeUtils: com.castortech.iris.emf.irisdb.custom.api.BaTypeUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1177] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreAttributeUtils: com.castortech.iris.emf.irisdb.custom.api.CoreAttributeUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1204] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreClassUtils: com.castortech.iris.emf.irisdb.custom.api.CoreClassUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1172] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreInstanceUtils: com.castortech.iris.emf.irisdb.custom.api.CoreInstanceUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1203] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreModelHelper: com.castortech.iris.emf.irisdb.custom.api.CoreModelHelper SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1164] from bundle 125 (com.castortech.iris.core.modelHelper.provider:1.0.0.qualifier)
  - coreOptFeatureUtils: com.castortech.iris.emf.irisdb.custom.api.CoreOptFeatureUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1202] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreRelationshipUtils: com.castortech.iris.emf.irisdb.custom.api.CoreRelationshipUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1205] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreSessionUtils: com.castortech.iris.emf.irisdb.custom.api.CoreSessionUtils SATISFIED 0..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1650] from bundle 7 (com.castortech.iris.ba.session:1.0.0.qualifier)
  - coreStereotypeHelper: com.castortech.iris.emf.irisdb.custom.api.CoreStereotypeHelper SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1168] from bundle 141 (com.castortech.iris.irisdb.core:1.0.0.qualifier)
  - coreStereotypeUtils: com.castortech.iris.emf.irisdb.custom.api.CoreStereotypeUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1169] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreTypeUtils: com.castortech.iris.emf.irisdb.custom.api.CoreTypeUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [196] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - coreUtils: com.castortech.iris.emf.irisdb.custom.api.CoreUtils SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1165] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)
  - genericExpressionResolver: com.castortech.iris.utils.eclipse.iemf.custom.GenericExpressionResolver SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [188] from bundle 211 (com.castortech.util.eclipse.emf:1.0.0.qualifier)
  - htmlService: com.castortech.util.html.IHtmlService SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [383] from bundle 131 (com.castortech.util.html:1.0.0.qualifier)
  - irisImage: com.castortech.iris.image.IrisImage SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1162] from bundle 215 (com.castortech.iris.image.provider:1.0.0.qualifier)
  - localizationHandler: com.castortech.util.i18n.LocalizationHandler SATISFIED 0..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [2194] from bundle 233 (com.castortech.iris.ba.i18n:1.0.0.qualifier)
  - notificationHelper: com.castortech.iris.emf.irisdb.custom.api.NotificationHelper SATISFIED 1..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [197] from bundle 237 (com.castortech.iris.emf.irisdb:1.0.0.qualifier)

  - stereoFeatureHelper: com.castortech.iris.emf.irisdb.custom.api.StereoFeatureHelper SATISFIED 0..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [1410] from bundle 125 (com.castortech.iris.core.modelHelper.provider:1.0.0.qualifier)
  - timestampableElementUtils: com.castortech.iris.emf.irisdb.custom.api.TimestampableElementUtils SATISFIED 0..1 dynamic
    target=(*) scope=bundle (1 binding):
    * Bound to [198] from bundle 112 (com.castortech.iris.models.ecore.meta:1.0.0.qualifier)

And we can see that it points to 197
osgi> service 197
com.castortech.iris.emf.irisdb.custom.utils.impl.NullNotificationHelperImpl@1fe949aa

BTW, if the application is already bootstrapped and thus activates the referencing component much later after all 3 instances have been activated, then the one with the highest service ranking is used and all is well.

In the same realm and with the same component, I'm facing another issue. And please note that this is not new code but just now called earlier in the startup process.

Here I have a service tracker used to be my service reference for the ActivatorComponents shown in my previous email.

Listing services from the console or using our internal tool returns:
osgi> checkRefs com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents
Checking for com.castortech.iris.emf.irisdb.custom.activator.ActivatorComponents references
  Referenced service com.castortech.iris.emf.irisdb.custom.api.BaTypeUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreAttributeUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreClassUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreInstanceUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreModelHelper/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreOptFeatureUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreRelationshipUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreStereotypeHelper/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreStereotypeUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreTypeUtils/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.CoreUtils/dynamic is registered
  Referenced service com.castortech.iris.utils.eclipse.iemf.custom.GenericExpressionResolver/dynamic is registered
  Referenced service com.castortech.util.html.IHtmlService/dynamic is registered
  Referenced service com.castortech.iris.image.IrisImage/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.NotificationHelper/dynamic is registered
  Referenced service com.castortech.iris.emf.irisdb.custom.api.TimestampableElementUtils/optional,dynamic is registered

indicating that all dependent referenced services are registered and ready to go. Why wouldn't the service tracker return a service reference for it? BTW, we use a retry process that is tested a number of times over about 5 secs, just to make sure that things get resolved. I have never seen this before.

Running very low on ideas about this mess.What am I missing?

Thanks
Alain


Back to the top