Marcel, thanks a bunch! I can just make a Services.java for each of the bundles and just put all the possible services that the bundle needs there. That way I am still using OSGI to populate those services to ensure the dependencies but then I don't have to worry about them in the actual UI components. Just in time too because I was about to revert everything and say it was a lost cause and roll my own services registry for the client.
Brendan Haverlock WebReach, Inc. Software Engineer Work: 949-255-5054 AIM: wr brendanh -----Original Message----- From: Marcel Offermans [mailto:marcel.offerm...@luminis.nl] Sent: Friday, April 17, 2009 2:38 PM To: users@felix.apache.org Subject: Re: Migrating a UI to OSGI On Apr 17, 2009, at 23:19 , Brendan Haverlock wrote: > Thanks for the replies guys! You're welcome. > Well, this is so odd though because I mean a lot of my components > take in > parameters to the constructor and I don't just have one instance of > that > component. I make multiple components based on what params are > passed in. > Setting the implementation class will just inject into one instance > of these > classes. And, a lot of times these UI components need to make calls > to > other services from their constructor, so adding them to the manager > breaks > them because the other services aren't injected at that point. Another way is to have one "singleton" in your bundle that has all service references. A singleton inside an OSGi bundle will be local to that bundle, and if you don't export it, nobody else can see it, so from a design point of view it's not that bad. So start with something like: manager .add(createService().setImplementation(Services.getInstance()).add( /* all dependencies you need */ )); and have a Services class something like: public class Services { public static Services instance; public static Services getInstance() { /* implement singleton here */ }; public volatile MyFirstInjectedService m_s1; public volatile MySecondInjectedService m_s2; // etc.. } and use them in your Swing components like this: Services.getInstance().m_s1.invokeSomeMethod(); Greetings, Marcel --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@felix.apache.org For additional commands, e-mail: users-h...@felix.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@felix.apache.org For additional commands, e-mail: users-h...@felix.apache.org