Thanks Dennis! That does make some sense, but isn't it still silly to have to implement all those methods (init, start, stop) on simple swing components?
Or, do I just implement the start() method since I'm not going to be adding it to the manager, and then put the code that I use to initialize the swing component there instead of the current method? I just want to make sure that I do this the "right" way. Brendan Haverlock From: Dennis Geurts [mailto:[email protected]] Sent: Friday, April 17, 2009 12:50 PM To: [email protected] Subject: Re: Migrating a UI to OSGI Hi Brendan, Good to see you are using the dependency manager! The choices you need to make are indeed difficult, so there others might have more to say about that. one little pointer: Since you are using the dependency manager; you do not necessarily need to call 'manager.add(svc)' to instigate the dependency injection, it suffices to call svc.start(), thus, your ui components are NOT registered as services, but DO get injected with the dependencies you define... Regards, Dennis On 17 apr 2009, at 20:03, Brendan Haverlock wrote: Hi all, I am currently migrating our application to use the OSGI framework on both the client and server programs. The server portion of the program was relatively straightforward, however, I am having some difficulties adapting OSGI to the client architecture. Basically, I've refactored every client package to expose its own service. However, there are so many GUI classes and components that have dependencies to other services that I don't really know what to do. I don't want to make every UI component its own service because I know there has to be a better way. Is there a way to specify that a component is a dependency and needs the service injection into one of its fields, but it isn't a service itself? Right now, I am creating my service dependencies as follows: public class UserBundleActivator extends DependencyActivatorBase { public void init(BundleContext context, DependencyManager manager) throws Exception { Service svc; // Service implementations svc = createService().setInterface(UserService.class.getName(), null).setImplementation(UserServiceImpl.class); svc.add(createServiceDependency().setService(CoreService.class).setRequired( true)); svc.add(createServiceDependency().setService(ExtensionService.class).setRequ ired(true)); manager.add(svc); // Non-service dependencies // UI component dependencies here? } Please help because I know there has to be a better way. Thank you! Brendan Haverlock No trees were killed in the sending of this message. However, a large number of electrons were terribly disturbed! ------------------------------------------------- Dennis Geurts luminis iQ Products B.V. K.v.k Centraal Gelderland: 09 16 28 93 ------------------------------------------------- +31 6 12078236 [email protected] www.luminis.nl <http://www.luminis.nl/> -------------------------------------------------

