I've been using Spring DM, and one thing that I'm struggling with is that a 
bundle that exports a service is unable to use that service. This seems to be a 
feasible design option, and I'm wondering what others have done to work around 
it. 

For instance, let's say I have three bundles.

BundleA with Interface1, Interface2, Interface1Impl, and Interface2Impl1.
BundleB with Interface2Impl2
BundleC with ClassC that uses Interface1.

On start, BundleA registers two new services Interface1Service and 
Interface2Service, using Interface1Impl and Interface2Impl1 as their 
implementations, respectively. As it happens, the Interface1Impl requires an 
Interface2 type, so using Spring DM, I've tried injecting the Interface2 
service into the Interface1 service. It doesn't work because Spring DM doesn't 
allow a bundle to use a service it registers, so I inject it as a regular bean. 

I want to do this because I install BundleB and register another 
Interface2Service service, now using Interface2Impl2. Because I cannot inject 
the service backed by Interface2Impl1 into the service backed by 
Interface1Impl, the service backed by Interface1Impl won't be able to use 
Interface2Impl2. 

FWIW, I can move Interface2 and Interface2Impl1 to a separate bundle and 
register it as a service. That does work, but it's not the application 
structure I want.

Possibly there is an alternative design to this that is more suitable to this 
situation. I'm just not sure what that is at this point. Any suggestions are 
appreciated. 

I can send code if it would be helpful to illustrate this.

Kirk Knoernschild
http://www.kirkk.com
http://techdistrict.kirkk.com
http://planet.kirkk.com
twitter: pragkirk




Reply via email to