-
Notifications
You must be signed in to change notification settings - Fork 782
added lazy activation to smarthome.core #1912
Conversation
Signed-off-by: Kai Kreuzer <kai@openhab.org>
Please do not merge yet - I assume that this small change makes some tests failing (https://travis-ci.org/eclipse/smarthome/builds/147154102). We will first have to figure out, whether this is a problem with the tests or if they actually hint at some lifecycle problem within our code base. |
What's the reason to use lazy activation at all? |
See the warning that Eclipse shows you on the MANIFEST.MF: |
That message is already discusses in some Eclipse IDE bugs. A bundle is always activated before a service of a bundle is activated. That is defined by the OSGi spec. |
This sounds differently: "It's not just Equinox that will only consider DS descriptors in active (or lazy-activated) bundles -- that's in the DS spec" The lazy activation is hence triggered here once other services access exported interfaces of this bundle. And this imho makes sense, because if you e.g. implement a BindingInfoProvider, you automatically assume that the BindingInfoRegistry service is started as well, which will pick up and use your service. |
I have written that a bundle is activated before a service of that bundle is activated. The lazy activation does not change the order between activation of the bundle and the activation of the services. But I don't think we need to care about "delay the activation of smarthome.core until a class is loaded" because I don't think it makes sense to install smarthome.core without using it at all. |
Which means that you assume that the bundle is always started anyhow. But this PR shows that some tests do NOT start the bundle and that in the case it IS (lazily) started, the tests fail. And this is exactly the reason why I think the "why" needs to be analyzed, because it is well possible that there is indeed some bug for certain startup orders, don't you think? |
If there is something wrong it needs to be analysed and resolved. Sure. Perhaps my reading has been wrong.
If there is no problem if we don't introduce it, we can analyse the startup order, too. But is there really a need for? |
I added it for highlighting a problem (failing test due to different startup behavior). Your argument is always: The BAPL is not required as it does not make any difference - well, this PR shows that it does. And again, I think it always makes sense to have a bundle started, if any of its exported classes is used, don't you agree? To make sure that this is the case, BAPL is required (even for non Eclipse RCP apps).
If it is only the test that has a problem, I agree that it is low prio. But if the test actually shows a problem that can occur on certain bundle startup orders (and ESH does not define any constraints here, right?), the prio can be high, because it means that some core functionality (i18n support) is broken. |
@kaikreuzer That is not what I have written. I have written, that it does not make any difference for the order of the DS and bundle activation. So, you have asked me this some time and now I do the same: Please do not shorten what I have written. If you really think that using BAPL a service of the bundle is present before the bundle of the activator is called then this is really a bug that should be inspected. But the fact that the bundle is not activated as long as a class of the bundle is accessed and so a service provided by the bundle activator is missing, is AFAIK the topic, expected behaviour. I will have a look at this bug after my vacation, but I assume the problem is that the bundle is not activated at the time another one expected an activated and (and the problem is not the order of DS and bundle activator). |
I agree that I would like to remove start levels and if the test relies on the fact that smarthome.core is activated before and that is broken, then there is a wrong assumption that should be fixed. Will have a look at. |
I didn't refer to your statements in this issue, but to our past discussions (where I cannot find a link right now, but the essence that I thought to remember was that "BAPL is only required for Eclipse RCP and isn't relevant for a headless OSGi app" - if I made this up, please forgive me and ignore it. I think the main question which we have to answer ourselves first is: Is it ok that the application allows using classes from bundles that are not started? To me it always feels weird and rather misleading if a bundle is not started, but only resolved (e.g. when listing the bundles in the console), but still it is under heavy use by others (not talking about DS at all here). This is e.g. a likely situation for API-bundles. For me, it feels much more natural and clear if the above question is answered with "no" (being aware that the OSGi spec does not require this to be the case). |
I checked why the If the immediate attribute from the As a result it seems that we have some dependency issues when starting the core framework. |
Signed-off-by: Kai Kreuzer kai@openhab.org