Hello Brendan, Dennis,

On Apr 17, 2009, at 21:50 , Dennis Geurts wrote:

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...

This is not entirely correct, Dennis. You should add services to the manager, and not start them yourselves. If a service does not define an interface, ie there is no .setInterface() call, then no service will be published.

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?

Yes, there is a way to inject depencencies into a whole collection of objects, if that collection itself remains unchanged.

Check out this page:

http://felix.apache.org/site/dependency-manager-usage.html

specifically, look at the "Using compositions" part. Say you have a UI, which is basically build out of a big tree of components, then you can inject dependencies into all those components by having that getInstance() call return all of them.

Greetings, Marcel


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to