The correct solution is to import these packages with Import-Package, just like 
every other package you depend on. The only “special” packages are java.* and 
this is because of a security restriction in the JVM.

If you don’t want people to declare dependencies on the packages they use then 
you should use a tool like bnd (or the maven bundle plugin, which is based on 
bnd), which will automatically discover and declare the imports for you.

Regards,
Neil


On 25 July 2014 at 11:01:20, Benjamin Rogge ([email protected]) 
wrote:

Hello,  
we are using apache felix 4.2.1 as an embedded OSGi container and use  
OSGi bundles as a plugin mechanism in our application. Our understanding  
is, that bundles can use java.* packages, but not other packages, such  
as org.w3c.dom or javax.xml.parsers.  

My question is, is there a way to expose all of the packages included in  
the Java runtime to all OSGi bundles?  

We tried to add the packages mentioned above to the  
"org.osgi.framework.system.packages.extra" property, but without the  
desired effect. The classes were not found in the bundle.  

We tried two things, that made the classes available, but we are not  
100% satisfied with these solutions:  
1. We added the packages to the "org.osgi.framework.bootdelegation"  
property and the classes will be available to the bundle, but we prefer  
another solution, because we feel, we broke modularity of the bundles  
with this property.  

2. We added the packages to the <import-package> in the bundle manifest  
and the classes will be available to the bundle, but we would prefer a  
solution where we won't have to add these packages to every bundle (the  
bundle will be developed by users of the application and not by us).  

Thanks for you help,  
Benjamin Rogge  

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

Reply via email to