Home » Eclipse Projects » Equinox » DS & lazy loading of services
|
Re: DS & lazy loading of services [message #503629 is a reply to message #503506] |
Mon, 14 December 2009 22:40 |
Ali Naddaf Messages: 85 Registered: July 2009 |
Member |
|
|
Hi Helmut.
If I am not mistaking, you are looking for the delayed components
(section 112.5.4 of the R4.2, for example). You can make a component
that provides a service either immediate or delayed. By default, DS
services are delayed unless you mark them as immediate in their xml
descriptor (if a component doesn't provide any services, then it is
enabled as soon as started).
If you were asking about something else, sorry for missing your question.
Ali.
Helmut J. Haigermoser wrote:
> Ciao @ll :)
> Congratulations on the DS implementation within Eclipse, I find it easy
> to use and a big helper to avoid some standard code for every service! :)
>
> Here comes my question: Is it possible to have a service that gets
> started at the time the first client tries to use it?
> Like, let's say I have a DS x.gui.Service providing a service for
> x.console.IService, and I want x.gui.Service to be first instantiated at
> the time a client actually needs to use the IService
> (BundleContext.getServiceReference("x.console.IService")), not at
> plug-in startup time? Right now I only see two flags, "start right away"
> (guess this forces a plug-in to load at startup) and "start once it's
> plug-in gets started", guess I want an additional "start once the
> service is needed"; kind of a dynamic/lazy approach...
>
> Thanks for your time, I have a hunch that this already works and I just
> need to learn how :) Ciao, hh
>
|
|
| |
Re: DS & lazy loading of services [message #504139 is a reply to message #503659] |
Thu, 17 December 2009 12:13 |
Helmut J. Haigermoser Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Re-hi everybody
Hm, I'm still unableto use DS the way I want to
Right now I'm ready to use an extension point, that way I know that I can decide when the extension is loaded (and the associated plug-in is started by that), but since extension points feel a bit more heavyweight I was really hoping to get this as a DS, can you guys again confirm the following is not possible:
plugin A defines a DS, interface "Interface"
plugin B defines an implementation for that interface: "Impl"
in plugin A I want to use the service, but with plugin B not having been started yet. I want the class "Impl" to be instantiated the moment I write "getService("Interface"), and plugin B should be started to make this happen if needed. If plugin B was already started, fine, but it should not be a prerequisite...
Sounds like a pretty standard use case, and seems to be covered by the osgi's "dynamic" specification of DS, so I'm wondering if I'm just doing this wrong, or setting the wrong property?
TIA,
Ciao, hh
|
|
|
Re: DS & lazy loading of services [message #504511 is a reply to message #504139] |
Mon, 21 December 2009 05:55 |
Alain Messages: 115 Registered: July 2009 |
Senior Member |
|
|
Hello,
You can use DS on your plugin B, so your service will be registered
without the need to start. And on your plugin A, use
bind(ServiceReference) which allow to bind your service without starting
it, then use locatService(String, ServiceReference) to get your service
instance (and activate it if needed)
Hope it help
Alain
On 12/17/09 7:13 PM, Helmut J. Haigermoser wrote:
> Re-hi everybody :)
> Hm, I'm still unableto use DS the way I want to :?
> Right now I'm ready to use an extension point, that way I know that I
> can decide when the extension is loaded (and the associated plug-in is
> started by that), but since extension points feel a bit more heavyweight
> I was really hoping to get this as a DS, can you guys again confirm the
> following is not possible:
>
> plugin A defines a DS, interface "Interface"
> plugin B defines an implementation for that interface: "Impl"
>
> in plugin A I want to use the service, but with plugin B not having been
> started yet. I want the class "Impl" to be instantiated the moment I
> write "getService("Interface"), and plugin B should be started to make
> this happen if needed. If plugin B was already started, fine, but it
> should not be a prerequisite...
>
> Sounds like a pretty standard use case, and seems to be covered by the
> osgi's "dynamic" specification of DS, so I'm wondering if I'm just doing
> this wrong, or setting the wrong property?
>
> TIA,
> Ciao, hh
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 16:49:03 GMT 2024
Powered by FUDForum. Page generated in 0.03359 seconds
|