Thanks for the replies guys! 

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.

Brendan Haverlock
WebReach, Inc.
Software Engineer
Work: 949-255-5054
AIM: wr brendanh

-----Original Message-----
From: Dennis Geurts [mailto:dennis.geu...@luminis.nl] 
Sent: Friday, April 17, 2009 1:56 PM
To: users@felix.apache.org
Subject: Re: Migrating a UI to OSGI


Thanks Marcel; I didn't know that ! lol, never considered NOT setting an
interface...

dennis

On 17 apr 2009, at 22:49, Marcel Offermans wrote:

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

Reply via email to