[
https://issues.apache.org/jira/browse/FELIX-5739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244224#comment-16244224
]
Thomas Watson commented on FELIX-5739:
--------------------------------------
If there is an ordering issue in the case where the activation policy is
actually configured to be used then it seems like that would be an Equinox
issue. I suggest you open a bug with Equinox if that is the case. But for
your consistently failing case, it sounds like the bundle is not be marked to
use the activation policy at all. The Felix DS method:
org.apache.felix.scr.impl.ComponentRegistry.isBundleActive(Bundle)
This method should check
org.osgi.framework.startlevel.BundleStartLevel.isActivationPolicyUsed() before
returning true in the STARTING case. If the activation policy is not set to be
used then even though the bundle says its activation policy is 'lazy' the
framework will behave as though the bundle does not and it will treat it as an
eagerly activated bundle. In this case it will not activate it automatically
on first class load.
> Strange behaviour with Lazy-ActivationPolicy and autostart
> ----------------------------------------------------------
>
> Key: FELIX-5739
> URL: https://issues.apache.org/jira/browse/FELIX-5739
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-2.0.10
> Environment: felix.scr 2.0.10
> eclipse 4.7.0
> equinox
> windows
> Reporter: Marko Herchet
> Priority: Minor
>
> Iam using felix.scr with Equinox (e4 application)
> Scenario:
> Bundle A has Bundle-ActivationPolicy: lazy
> Bundle A has startLevel=4
> Bundle A provides Service S1 via ComponentDefinition
> Bundle B listens for REGISTER-Event of S1 and retrieves it via
> BundleContext.getService(serviceEvent.getServiceReference())
> When Bundle A has autostart = false everything behaves as expected:
> * Equinox-ModuleContainer increases actual level to 4
> * Equinox-ModuleContainer starts lazyOnly-Bundles with StartLevel 4
> * Bundle A BundleState changes to STARTING
> * felix.scr reacts to BundleEvent for STARTING of Bundle A, and parses the
> ComponentDefinitions
> * felix.scr registers a ServiceFactory for S1
> * Bundle B reacts to ServiceEvent for REGISTER of S1 and calls
> BundleContext.getService(serviceEvent.getServiceReference())
> * The ServiceFactory for S1 loads Class of S1
> * The responsible Equinox-BundleClassLoader starts Bundle A
> * Activator#start of Bundle A is called
> * Instance of S1 is created
> * S1.activate() is called
> When Bundle A has autostart = true something (in my opinion) weird happens:
> * Equinox-ModuleContainer increases actual level to 4
> * Equinox-ModuleContainer starts lazyOnly-Bundles with StartLevel 4
> * Bundle A BundleState changes to STARTING
> * felix.scr reacts to BundleEvent for STARTING of Bundle A, and parses the
> ComponentDefinitions
> * felix.scr registers a ServiceFactory for S1
> * Bundle B reacts to ServiceEvent for REGISTER of S1 and calls
> BundleContext.getService(serviceEvent.getServiceReference())
> * The ServiceFactory for S1 loads Class of S1
> * The responsible Equinox-BundleClassLoader (!) DOESNT start Bundle A
> * Instance of S1 is created
> * S1.activate() is called
> * Equinox-ModuleContainer starts autostartedOnly-Bundles with StartLevel 4
> (module#start returns fast for Modules that are not autostarted)
> * Activator#start of Bundle A is called
> * Bundle A BundleState changes to ACTIVE
> In this case we have a Lazy-BundleA and its services #activate-Method is
> called before its Activator#start... should this even be possible?
> I'm not sure why one would even use LazyActivationPolicy in combination with
> autostart but I'm pretty sure it didnt behave this way before we updated to
> eclipse-oxygen and felix.scr
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)