Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » DS and Spring beans
DS and Spring beans [message #540112] Tue, 15 June 2010 00:29 Go to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
We have a mix of OSGi DS services (Declarative Services components) and
Spring beans and services. Is it possible to use a Spring bean as a
property of a DS service, i.e. inject the Spring bean into the DS
service? Would it help if the Spring bean were declared as a service
using Spring DM?

Craig
Re: DS and Spring beans [message #540169 is a reply to message #540112] Tue, 15 June 2010 08:36 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Craig,
using Spring DM it's easy to inject a bean into a service implementation
and vice versa.

I don't think that its possible to inject a Spring bean into a service
component created with Equinox DS as the lifecycle of the object is not
known to Spring.

What you of course can do is publish an OSGi service using Equinox DS
and consume it with Spring DM or vice versa.

Regards,
Stefan.

Craig Foote schrieb:
> We have a mix of OSGi DS services (Declarative Services components) and
> Spring beans and services. Is it possible to use a Spring bean as a
> property of a DS service, i.e. inject the Spring bean into the DS
> service? Would it help if the Spring bean were declared as a service
> using Spring DM?
>
> Craig
Re: DS and Spring beans [message #540306 is a reply to message #540169] Tue, 15 June 2010 15:13 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
Thanks for replying Stefan, this looks promising.

Regarding exposing a Spring bean as a DM service and consuming it in a DS component service, do you have an example?

Does the DS XML declaration reference the DM service by id or interface? Does the resolution of that dependency require the bundle declaring the Spring bean be started? If so, how should it be started?

I like DS in that the first consumer of the service starts the service bundle automagically while I had problems with DM services not being available if the declaring bundle is not somehow started.

Any help greatly appreciated!

Craig

[Updated on: Wed, 16 June 2010 00:44]

Report message to a moderator

Re: DS and Spring beans [message #543423 is a reply to message #540112] Tue, 29 June 2010 11:24 Go to previous message
bartosz michalik is currently offline bartosz michalikFriend
Messages: 14
Registered: July 2009
Junior Member
On 06/15/2010 02:29 AM, Craig Foote wrote:
> We have a mix of OSGi DS services (Declarative Services components) and
> Spring beans and services. Is it possible to use a Spring bean as a
> property of a DS service, i.e. inject the Spring bean into the DS
> service? Would it help if the Spring bean were declared as a service
> using Spring DM?
>
> Craig

A long time ago I have created such a example:

http://eclipser-blog.blogspot.com/2008/12/osgi-example-sprin g-dynamic-modules.html

maybe it can be helpful.

best regards,
Bartek
Previous Topic:PDE ignores p2.inf
Next Topic:Bundle stay always in the state "RESOLVED"
Goto Forum:
  


Current Time: Fri Apr 19 23:48:11 GMT 2024

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

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

Back to the top