Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Lazy service activation in Gemini Blueprint
icon5.gif  Lazy service activation in Gemini Blueprint [message #550412] Fri, 30 July 2010 09:56 Go to next message
Christian Kesselheim is currently offline Christian KesselheimFriend
Messages: 59
Registered: June 2010
Member
Hello everyone,

just wanted to know if there was something similar to Declarative Services' "lazy service activation" in Gemini Blueprint?

What's the best way to automatically start an implementor bundle (as well as the actual service implementation itself) as soon as the service interface get's requested for the first time?

E.g.

my.company.blah.impl (providing MyServiceImpl)

should be activated as soon as a service instance of

my.company.blah.api.IMyService (from my.company.blah.api)

is requested by another bundle.

So far, the only way I see is either fiddling with the autostart/start level settings of the implementor bundle or setting all my bundles to auto-start by default.

Thanks in advance,

Chris
Re: Lazy service activation in Gemini Blueprint [message #550816 is a reply to message #550412] Wed, 04 August 2010 12:27 Go to previous messageGo to next message
Costin Leau is currently offline Costin LeauFriend
Messages: 45
Registered: February 2010
Member
There are various ways to do that.
First one can mark a service as lazy - in which case it will get activated only on first request. Secondly, one can implement the OSGI ServiceFactory interface which Gemini Blueprint recognizes and delegates to.
This gives you full access to the OSGi semantics.

Outside the Blueprint spec (which I recommend reading) you can use Gemini Blueprint own 'bundle' scope (see the Spring documentation regarding bean scopes).

Hope this helps,
Re: Lazy service activation in Gemini Blueprint [message #550846 is a reply to message #550816] Wed, 04 August 2010 13:45 Go to previous messageGo to next message
Christian Kesselheim is currently offline Christian KesselheimFriend
Messages: 59
Registered: June 2010
Member
Hi Costin,

thanks for your reply.

I must have had misconceptions on the actual semantics of lazy, ServiceFactory and bundle scope so far.

For example, my previous understanding of lazy/ServiceFactory was that its use would only defer the instantiation of the actual service bean instance till the point at which it was really required, e.g. the time when the first of its operations got invoked from the outside.

So what you say is that I can somehow make Spring DM/Gemini automatically register OSGI service endpoints for services whose hosting bundles are not yet activated but only resolved (and then activate these bundles automatically as soon as the first real invocation spins-in)?

Unfortunately, I'm still not (yet) able to reproduce the behavior you describe (I still need to activate the bundles first before their services are being registered).

Still, thanks for your help so far.

Chris

Re: Lazy service activation in Gemini Blueprint [message #555262 is a reply to message #550846] Thu, 26 August 2010 06:48 Go to previous message
Costin Leau is currently offline Costin LeauFriend
Messages: 45
Registered: February 2010
Member
Seems we are talking about two different types of lazy here:
OSGi bundle lazy - meaning the bundle is not active and no class loading is performed
bean/instance lazy - as in Spring sense, meaning the actual instance is not created yet.

The first is not supported in Spring DM/Blueprint since it's impossible to guarantee. For example, in order to register a ServiceFactory, one would have to know how to create a bean instance which means it would have to know how to create the instance (class loading included).
Additionally, many tools or libraries perform bundle scanning which automatically triggers class loading.
Further more, unless the service is registered, a bundle is likely to not ever get activated since there are no 'triggers' for that - unless somebody explicitly locates the bundle and loads an (existing) class, there is nothing in the service registry to pick on.

Hope this helps,
Previous Topic:Enterprise Modules Project (Gemini) FAQ
Next Topic:Gemini on Equinox 3.6
Goto Forum:
  


Current Time: Tue Mar 19 05:20:03 GMT 2024

Powered by FUDForum. Page generated in 0.03018 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top