You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Dorian Vegara <do...@gmail.com> on 2017/03/12 20:13:52 UTC

How to compile classes in different packages ?

Hello to everyone,


I wrote three bundles : a provider (providing a service|A|), a client 
(containing one `BundleActivator` class using this service|A|) and a 
service (containing the interface|A|). Each bundle is, obviously,*in its 
own package*.

The problem is that my client, for example, instantiates an object|:A|. 
So I should write|import package.to.A|to compile my client.

But I don't think I should do this in OSGI. I'm using Apache Felix, and 
I indicated the champ|Import-Packages|in the|META-INF/manifest.mf|: is 
there any command in Felix to compile my client without having to write 
the|import|?


Thank you in advance.
Best regards,
Dorian VEGARA


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus

Re: How to compile classes in different packages ?

Posted by David Jencks <da...@gmail.com>.
I don’t quite understand what you are describing.

Normally you want a service to implement an interface, say a.A.  The service implementation would be in a different package say b, so you’d have b.AImpl implementing a.A.  It’s usually most convenient to have both packages a and b in  the same bundle.  Package a will be exported, and package b will NOT be exported.  There are various techniques for setting up one or more instances of the service, usually the most convenient and flexible way is to use DS (SCR).  Any other classes needed by a.A such as data parameters to methods need to be available to clients as well, usually by putting such classes also in package a.

It’s rarely a good idea to use services in a BundleActivator….. what is supposed to happen if the services aren’t there?  Usually it’s better to put the functionality into a DS component with a reference to the service you want to use.

hope this helps

david jencks

> On Mar 12, 2017, at 1:13 PM, Dorian Vegara <do...@gmail.com> wrote:
> 
> Hello to everyone,
> 
> 
> I wrote three bundles : a provider (providing a service|A|), a client
> (containing one `BundleActivator` class using this service|A|) and a
> service (containing the interface|A|). Each bundle is, obviously,*in its
> own package*.
> 
> The problem is that my client, for example, instantiates an object|:A|.
> So I should write|import package.to.A|to compile my client.
> 
> But I don't think I should do this in OSGI. I'm using Apache Felix, and
> I indicated the champ|Import-Packages|in the|META-INF/manifest.mf|: is
> there any command in Felix to compile my client without having to write
> the|import|?
> 
> 
> Thank you in advance.
> Best regards,
> Dorian VEGARA
> 
> 
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
> https://www.avast.com/antivirus


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org