Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] In which thread are OSGI services started

The DS specification says nothing about what thread a DS component's method is invoked upon. It may be someone else's thread or a thread that SCR manages in an executor. But as a component implementer you MUST NOT assume anything about the thread upon which your component's methods are invoked. (Other than it is not your thread to use for long periods of time.)
--

BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargrave@xxxxxxxxxx
 
 
----- Original message -----
From: Lars Vogel <lars.vogel@xxxxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx
To: Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
Cc:
Subject: [EXTERNAL] Re: [equinox-dev] In which thread are OSGI services started
Date: Wed, Sep 4, 2019 14:44
 
Thanks Neil and BJ. What if I use OSGi ds (Felix) to define the service? 
 
 
Best regards, Laes
 
Neil Bartlett <njbartlett@xxxxxxxxx> schrieb am Mi., 4. Sep. 2019, 14:44:
Short answer is that you should not make any assumption about the thread that your component is activated.
 
Long answer is that for an immediate component, it is likely to be activated in whichever thread called Bundle.start(). For a lazy service component, it is likely to be activated in whichever thread called BundleContext.getService().
 
But the outcome is the same. You are always "borrowing" a thread and should never do long running work in the activate method of a component. If you have any such work to do, then you should spin it out as a thread or submit it to an executor service.
 
Neil
 
On Wed, 4 Sep 2019 at 13:41, Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
Friends of Equinox,

If I create an immediate OSGi service, in which thread is it created?
How about lazy OSGi services?

The background of my question is that I would like to replace an
Eclipse early startup extension with an immediate OSGi but I'm not
sure if that would block the main thread until the service has been
created.

Best regards, Lars

--
Eclipse Platform project co-lead
CEO vogella GmbH

Haindaalwisch 17a, 22395 Hamburg
Amtsgericht Hamburg: HRB 127058
Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
USt-IdNr.: DE284122352
Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/equinox-dev
 


Back to the top