Is there a way I can just ask the service registry for the implementations
of the services in these non-service UI classes instead of trying to inject
them?  If I can set the fields manually from the registry, then everything
will work fine.  Otherwise, I can't see this ever working because all the
constructors in my UI components need to use the other services to gain
access to components to, for example, set the owning JFrame.  

Thanks!

Brendan Haverlock

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