File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Using third party libraries with OSGi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Using third party libraries with OSGi" Watch "Using third party libraries with OSGi" New topic
Author

Using third party libraries with OSGi

Migue Carvajal
Greenhorn

Joined: Feb 02, 2011
Posts: 5

Hi again,

We have had some trouble using third party libraries in OSGi. Sometimes, our approach has been "bundlelize" the library, and this has revealed new troubles related to dependencies with other libraries, this end in a very big bundle containing a lot of dependent components.
Do you recommend any strategies to cope with this situations?

Thanks in advance,
Richard S. Hall
author
Ranch Hand

Joined: Feb 14, 2011
Posts: 47
Migue Carvajal wrote:
We have had some trouble using third party libraries in OSGi. Sometimes, our approach has been "bundlelize" the library, and this has revealed new troubles related to dependencies with other libraries, this end in a very big bundle containing a lot of dependent components.
Do you recommend any strategies to cope with this situations?


We cover this topic in the book. The simplest approach is to create one big self-contained bundle, but it depends on your situation. If you can already find bundle-ized versions of most of the dependencies, then keeping them separate is probably the best choice. This is definitely a hurdle when moving toward OSGi, but it is improving.
Augusto Sellhorn
Ranch Hand

Joined: May 24, 2007
Posts: 57
Richard S. Hall wrote:
The simplest approach is to create one big self-contained bundle, but it depends on your situation.


You mean embedded jars in the bundle? We ended up having to do that after bnd wrapping all dependencies wouldn't work in all cases.
Richard S. Hall
author
Ranch Hand

Joined: Feb 14, 2011
Posts: 47
Augusto Sellhorn wrote:
Richard S. Hall wrote:
The simplest approach is to create one big self-contained bundle, but it depends on your situation.


You mean embedded jars in the bundle? We ended up having to do that after bnd wrapping all dependencies wouldn't work in all cases.


Yes or just expanding them into the bundle, you don't necessarily need to embed the classes in their original JAR files.
Mike Van
Ranch Hand

Joined: Apr 06, 2006
Posts: 83
Richard S. Hall wrote:
Augusto Sellhorn wrote:
Richard S. Hall wrote:
The simplest approach is to create one big self-contained bundle, but it depends on your situation.


You mean embedded jars in the bundle? We ended up having to do that after bnd wrapping all dependencies wouldn't work in all cases.


Yes or just expanding them into the bundle, you don't necessarily need to embed the classes in their original JAR files.


Another approach you can use when making use of third party libraries that are not OSGi bundles, is to (in Karaf) wrap them when you install them.

For example, if you're installing a .jar file using the karaf console, and you want to wrap it as it is installed you'd do something like this:


This instructs Karaf to use the bnd library available in Karaf to wrap that non-OSGi bundle prior to installing it. The -s flag instructs Karaf to start the bundle once the jar is wrapped and installed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using third party libraries with OSGi