Aug 23rd, 2009, 02:23 PM
Bean dependency spanning bundles?
my application is composed of several DM-powered bundles and I need to split some funcionality in different bundles. E.g., I have a bundle "server.core" that is setting up the database and a bundle "server.remote" that enables remote communication for the server. Obviously, the bean definitions should be processed before than all the bean definitions in the "server.remote" bundle. I have already tried to define the "depends-on" attribute for the beans in "server.remote", but Spring isn't able to find them (I assume they are intended as local references).
Has anybody tips for me ?
Aug 24th, 2009, 02:06 AM
Do you expose the needed beans by the server.remote bundle as OSGi services? As a matter of fact, each bundle contains its own and independent Spring container and you can't do dependency injection between them with classic Spring reference... The best practise to make a bundle use beans of another bundle is to use the OSGi service registry. The latter allows making the link and provide a robust way to correctly handle OSGi dynamics (helped by Spring DM!)
Otherwise, if you want to force the start up of your server.core bundle before your server.remote bundle, you can use the startlevel feature of OSGi.
Hope it helps you!
Aug 24th, 2009, 03:48 AM
Yes, that helped a lot. Now I understand how this has to be done! I already knew that OSGI services can define dependencies, but what I was missing is the fact that you can create local "proxies" to bean services with "osgi:reference" !
Originally Posted by templth
Now everything works fine and as expected - Thank you very much!