OSGi service bundle start options - noobie [message #498687] |
Tue, 17 November 2009 23:30  |
Eclipse User |
|
|
|
We're using Eclipse to create 3 bundles, one defining a service
interface, another with a service implementation, and another consuming
the implementation using a ServiceTracker. We're using SpringDM so the
implementation bundle has a /META-INF/spring/bundle-context.xml declaring
a bean of type [ServiceImpl] and registers it under interface [Service].
The service consuming plugin's ServiceTracker is returning a null service
and debugging in the OSGi console indicates the ServiceImpl bundle is in
Lazy state. I understand the DM extender will register the service once
this bundle starts but I'm unsure how to start it. I know of 4 options
but would appreciate others and advice on best practice:
1. instantiate a class in the ServiceImpl bundle from another bundle -
unwanted coupling
2. add the ServiceImpl bundle to the .product's config.ini - unwieldy
and unmanageable in distributed system, i.e. many groups writing service
bundles
3. use a bundles.info file with SimpleConfigurator - I'm not real
familiar with this but it seems the same as option 2 in that it seems to
require a central list of bundles to start
4. create a plugin with a startup extension which uses its
bundlecontext to start appropriate bundles - this seems like a workaround
or hack to me
To clarify requirement, we need a process by which relatively independent
groups write plugins and service bundles for inclusion in a common
eclipse product. Each group needs to manage the starting of its own
service bundles. We want to suggest they use bundle-context.xml's to
declare services and letting the DM extender register them... once we
figure out how to start them :)
Thanks in advance,
Craig Foote
|
|
|
|
Re: OSGi service bundle start options - noobie [message #498903 is a reply to message #498778] |
Thu, 19 November 2009 00:49  |
Eclipse User |
|
|
|
Hi Paul, thanks for replying.
I like the Declarative Services idea because it minimizes dependencies. I
did a quick test and I was able to consume a declared service without
explicitly starting the bundle. Nice.
Thanks again,
Craig
On Wed, 18 Nov 2009 10:34:04 -0500, Paul Webster wrote:
> If I read Spring DM right (that the extender can only see bundles after
> they've been activated) then you're going to have to do the leg work
> yourself.
>
> 3 options that come to mind:
>
> 1) require everybody that provides a bundle-context.xml to use
> org.eclipse.ui.startup ... their IStartup implementation will be called
> after the workbench/workbench windows have been created (now the bundles
> are activated)
>
> 2) create your own extension point that bundle-context.xml providers use
> ... then your engine that reads the extension point can start up the
> bundles you want whenever necessary.
>
> 3) use eclipse DS (the first call to get a service activates the
> providing bundle) either by itself or in conjunction with your Spring DM
> ... the caveat being that someone still has to ask for the DS service in
> order to activate all the bundles.
>
> But I'm not 100% sure how Spring DM work on its side, I'm just guessing.
>
> PW
|
|
|
Powered by
FUDForum. Page generated in 0.06697 seconds