Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [osgi-users] Framework: Auto-Start of Bundles with Immediate DS Components
  • From: "Fauth Dirk (ETAS/ENA)" <dirk.fauth@xxxxxxxxxxxx>
  • Date: Fri, 30 Sep 2022 04:31:53 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=de.bosch.com; dmarc=pass action=none header.from=de.bosch.com; dkim=pass header.d=de.bosch.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kbhBbNRueOlY5NR5HWrSQ4k/D4rP3OQGiwb08wfeAOc=; b=E/9Qc1eLBgOse2IG0nTfmaxldbSkTd1wI13XinMjtZIGzubKSmKAmfAoJZ26qGez9sXGUWt7qGmS+fRJCgx2S34bhxmYNjrw+ENqJz4vAk7W6tbu1SkSiyrWOaEDhj98roTIZQ0dRJ2V+DKdhFBXSwLU4ckoypN+jm4UxYdvg/sb7qPKrMzdxhNuhjQiUm9e0ETix6U6HRt+vm1L3GihVZ/uoR0zWKSFHKSH0qQAfVdJ8KREQZVnnVEfo3uhamqxHzl/a5A0zh2jPqC0MtnWzJQVUIrCOClAzTUk+R5SbdWnw2JlxxkOnQvS8F3tTLD6XBRFNp85bcJfCp4aIOeOSg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K2+WMnDhBgX3dU2aX/nW7cwcQ9AqFnmpqVrihGtxVSNBk32+xhhOrNEVoREBip891x45fmB2mMzi9iS9kswkmygc7iZoJwPrgecC/eP03xoT26nJ7JyqELZ95PrdnYnyESIy9Pk6ccNMHJDEO62k+BuaEpnjomgu3XINADy0aG/z0+bIySSktzlrWf1wCXZQTAAk6ImAkV2g8Iwzbv4vKg1B75M84+kPHLunvuB9ehfJty7M7oJv0/0khpIXaVl84CgF+j4DD9cwXQhZ7cxS+zY9fyCDYB6JwBhmRAyIU4F+oY+hH4Yd0dXGIFHLF4SWfV+ggI4qxCY8JVJfAZRe5g==
  • Delivered-to: osgi-users@xxxxxxxxxxx
  • List-archive: <https://dev.eclipse.org/mailman/private/osgi-users/>
  • List-help: <mailto:osgi-users-request@eclipse.org?subject=help>
  • List-subscribe: <https://dev.eclipse.org/mailman/listinfo/osgi-users>, <mailto:osgi-users-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://dev.eclipse.org/mailman/options/osgi-users>, <mailto:osgi-users-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHY1BwI3BWwIPEUPE6cHLryE65zUa32lYMAgAAMbACAAMDu0A==
  • Thread-topic: [osgi-users] Framework: Auto-Start of Bundles with Immediate DS Components

Hi Konrad,

 

actually the answer is no. There are other ways to tell Equinox to autostart a bundle. Actually there are three ways:

 

  1. Set the Bundle-ActivationPolicy: lazy policy
  2. Configure the autostart setting in the config.ini
  3. Implement a custom Configurator that does this for you

 

You already know point 1. The second option is the manual bundle start configuration via config.ini explained here: https://www.eclipse.org/equinox/documents/quickstart-framework.php

The 3. option is something I did a few years ago when I struggled with the same topic: https://github.com/fipro78/equinox-autoconfigurator

 

And actually it is not really a decision of the OSGi implementation in its core. It is a launcher topic. Also Apache Felix does not automatically start every bundle. You have to configure it. But Felix has a global configuration that makes it easy to simply autostart all bundles. The bndlauncher from Bndtools automatically autostarts all bundles. Equinox made the decision to not autostart all bundles, to avoid startup delays because of operations done in Activators, which was a quite common pattern in Eclipse plugins at the beginning.

 

BTW, bringing bundles from RESOLVED to STARTED typically happens if some other bundle requests a class from it. For services this typically never happens if the interface is located in another bundle, because no one will ever request the service implementation class directly. And the same is true for an immediate component. No one will ever directly request an instance of the immediate component. Therefore the bundle will never be automatically activated by OSGi if that is the only thing in the bundle. At least if I remember correctly. 😊

 

 

Dirk Fauth
ETAS Advance Engineering

T +49 711 3423-2174
Dirk.Fauth@xxxxxxxx

ETAS GmbH, ETAS/ENA
Borsigstraße 24, 70469 Stuttgart, Germany
www.etas.com

ETAS – Empowering Tomorrow’s Automotive Software


Managing Directors: Christoph Hartung, Günter Gromeier, Götz Nigge
Chairman of the Supervisory Board: Dr. Walter Schirm
Registered Office: Stuttgart, Registration Court: Amtsgericht Stuttgart, HRB: 19033

Von: osgi-users <osgi-users-bounces@xxxxxxxxxxx> Im Auftrag von Konrad Windszus
Gesendet: Donnerstag, 29. September 2022 19:01
An: This is a community mail list for OSGi technology. Any OSGi technical discussion or questions are acceptable here. <osgi-users@xxxxxxxxxxx>
Betreff: Re: [osgi-users] Framework: Auto-Start of Bundles with Immediate DS Components

 

Hi Jürgen,

 

Thanks for the input.

But in fact what I see is the opposite:

 

Equinox does actually auto-start the bundle once it has the Bundle Header Bundle-ActivationPolicy: lazy being set, which feels wrong to me, as that bundle header should IMHO only defer starting, but in fact without it (i.e. default eager activation) the bundle won’t be started at all.

 

So it seems that using Bundle-ActivationPolicy: lazy seems to be the only way (when not relying on explicit start levels) I can make Equinox start my bundle.

 

IIUC the Core Spec defines how  Bundle-ActivationPolicy: lazy affects the bundle state transitions from STARTING -> ACTIVE but it does not really say anything about it affecting the state transition RESOLVED -> STARTING (https://docs.osgi.org/specification/osgi.core/8.0.0/framework.lifecycle.html#d0e9129)

So is it a decision of the container implementation when and if transitioning a bundle from RESOLVED to STARTING (when no explicit start method is called on it)?

 

Konrad

 



On 29. Sep 2022, at 18:16, Jürgen Albert <j.albert@xxxxxxxxxxxxxxxxxx> wrote:

 

Hi Konrad,

in my early days, I was under a similar impression and was wondering what the logic behind all this is. The first thing is: it is more of an eclipse then an OSGi thing.

Components:

Components by themself have no influence of on the starting behavior of the bundle it lives in. If a Bundle is Started (or even in state starting, not sure) DS will recognize it and handle its declared components. If a Component is a Service and has immediate=true, it will activate the service the moment all its references are satisfied. Components without a Service are immediate by default. Thus: DS will not start your Bundles.

Bundle-ActivationPolicy: lazy

After a Bundle is installed, the Framework tries to resolve it. So the Resolve states means, that all its Imports and Requirements are satisfied and it is exacted that all is classes can be properly loaded. At this point other bundles can load the Exported Classes from the Bundle. This does require a Bundle to be active. Active only means that a Bundle Activator (if present) was called and that Components, Configurations or what ever else lurks in the Bundle has started doing something.
If the Bundle-ActivationPolicy is not lazy, it will be started automatically after the resolve state. If I have read the code correctly, this is done by the launcher who sits outside and not really framework itself.

Equinox has a bit of a special handling. Its Launcher (called EclipseStarter) installs all configured Bundles and then tries to start them if they don't have the Lazy policy. It then goes through the Lazy List and tries to start them according to the configured start levels. (I hope I've gotten the order right here). So Lazy in the pure OSGi sense means, don't autostart as somebody will do it manually at some point.

So, when you want your Bundle to be started and your Components to be available don't set it to lazy (or in case of Eclipse and RCP you can also set a startlevel for it).

Hope this helps,

Jürgen.

Am 29/09/2022 um 17:56 schrieb Konrad Windszus:

Hi,
I observed an issue in Equinox with Bundles not being automatically started although they do have DS components with an immediate flag in it.

From https://docs.osgi.org/specification/osgi.core/8.0.0/framework.lifecycle.html#i3270328 it is not quite clear to me under which circumstances the framework can decide to leave a bundle in RESOLVED state.

It seems to depend on its internal autostart setting, which according to chapter 4.4.5 of OSGi Core can have one of three values:
              • Stopped - The bundle should not be started.
              • Started with eager activation - The bundle must be started once it is ready and it must then be eagerly activated.
              • Started with declared activation

Under which particular circumstances is a Framework supposed to start a bundle automatically (given its autostart setting is not set to Stopped)

1. Once a class is requested from it?
2. It defines some DS components (does the immediate flag matter here)?

What I observed is that Equinox does actually auto-start the bundle once it has the Bundle Header Bundle-ActivationPolicy: lazy being set, which feels wrong to me, as that bundle header should IMHO only defer starting, but in fact without it (i.e. default eager activation) the bundle won’t be started at all.

Thanks in advance for your PoV on this matter
Konrad

_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users


--
Jürgen Albert
CEO
Chair Eclipse OSGi Working Group Steering Committee


Data In Motion Consulting GmbH

Kahlaische Str. 4
07745 Jena

Mobil:  +49 157-72521634
E-Mail: j.albert@xxxxxxxxxxxxxxx
Web: www.datainmotion.de

XING:   https://www.xing.com/profile/Juergen_Albert5
LinkedIn: https://www.linkedin.com/in/juergen-albert-6a1796/

Rechtliches

Jena HBR 513025

_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users

 


Back to the top