views:

140

answers:

1

As the title suggests, I'm having problems with OSGI + Spring DM.

In my project design, i have a bundle A that requires a service svB and exports service svA. Bundle B requires svA and exports svB (among other things, of course). This seems to be causing a deadlock, as it appears both bundles are waiting for the other to go online. Is that sort of deadlock possible with Spring DM? Is there a solution to this?

+3  A: 

This doesn't sound like a problem with Spring-DM, rather you have set yourself up for this deadlock: A depends on B, B depends on A, thus no-one can get any work done. To break out of this, you probably need to change your design, and enable either one of A or B to start without the other. Meanwhile, the other one should have some lazy-loading logic built into it (this would be your job) and continue it's start-up sequence when the other one has come online on it's own.

With OSGi Declarative Services, you are able to declare a dependency on a service but allow it to be absent at the time you are going to start (do this using the cardinality option.)

omerkudat
Turns out this was exactly how I worked through this issue yesterday. I was gonna post the solution here but you beat me to it. Thanks anyways! =)
Eduardo Z.