views:

234

answers:

6

Hi,

I have a project that references a number of open source libraries, some new, some not so new. That said, they are all stable and I wish to stick with my chosen versions until I have time to migrate to the newer versions (I tested hsqldb 2.0 yesterday and it contains many api changes).

One of the libraries I have wish to embed is Jasper Reports, but as you all surely know, it comes with a mountain of supporting jar files and I have only need a subset of the mountain (known) therefore I am planning to custom bundle all of my dependant libraries.

So:

  • Does everyone custom-make their own OSGi bundles for open-source libraries they are using or is there a master source of OSGi versions of common libraries?

  • Also, I was thinking that it would be far simpler for each of my bundles simply to embed their dependent jars within the bundle itself. Is this possible? If I choose to embed the 3rd party foc libraries within a bundle, I assume I will need to produce 2 jar files, one without the embedded libraries (for libraries to be loaded via the classpath via standard classloader), and one osgi version that includes the embedded libraryy, therefore should I choose a bundle name like this <<myprojectname>>-<<subproject>>-osgi-.1.0.0.jar ?

  • If I cannot embed the open source libraries and choose to custom bundle the open source libraries (via bnd), should I choose a unique bundle name to avoid conflict with a possible official bundle? e.g. <<myprojectname>>-<<3rdpartylibname>>-<<3rdpartylibversion>>.jar ?

  • My non-OSGi enabled project currently scans for custom plugins via scanning the META-INF folders in my various plugin jars via Service.providers(...). If I go OSGi, will this mechanism still work?

+2  A: 

Perhaps you are looking for something like Maven? Not sure how that would work with OSGi though. You can find a little info on Jasper Reports with Maven here: http://mvnrepository.com/artifact/jasperreports/jasperreports

revil
The link is not for OSGi bundles. But its a nice link to see the dependancies of Jasper.
Chris
+3  A: 

I prefer to not embed the dependent jars (yes it is possible). It causes two problems,

1) There is no reuse of this code. Many bundles may simply do the same thing (embed the same jar) and you end up with the same jar installed many times. You can argue that your bundle can export the interfaces for the embedded jar as well, but this gets ugly since it should not be your bundles responsibility to expose that code. It also makes it easier to have multiple versions of the library exposed, or multiple providers of the same version.

2) This is Eclipse specific - The embedded jars don't resolve properly in the development environment (still works at runtime). My bundle may depend on a bundle in my target platform, and it will fail to resolve elements in the embedded jars, they have to be imported into the workspace to work.

I have found that most open source jars have already been kindly bundled by the nice folks at Spring. There are other repos available as well, but unfortunately I lost my links to them.

Robin
The Spring jars have Spring printed all over them plus they seem to be older versions of libraries (such as version 2.0.5 of Jasper Reports).OSGi seems nice in theory, but it seems that everyone is building their own bundles (including Spring) which kind of defeats the purpose. Not to mention the JDBC problem with OSGi.DLL hell was solved with the classpath. Classpath hell was solved with OSGi. What will save us from OSGi bundle hell?
Chris
@Chris - true enough on the naming, but since there isn't any central authority for providing the bundles and they aren't being created by the owner, it seems like a reasonable compromise. At least you know where it came from, and it makes no difference once it is deployed. As for it's usefulness, it is just another tool in the belt, quite useful for building pluggable type systems.
Robin
+1  A: 

The Eclipse Orbit project has also made bundles from many commonly used third party jars.

http://www.eclipse.org/orbit/

James Branigan
Thanks for the link. Unfortunately, my question remains though.
Chris
+1  A: 

To be specific about the questions you asked.

Everyone doesn't make their own. See my previous answer for a link to the Eclipse packaging of third party libraries as bundles. If you can't find and already packaged version, you'll have to make your own.

It is better to wrap binary dependencies in their own bundle than to include the jar as a binary into your code bundle. Pick whatever bundle name you want, its the package imports and exports that matter. Namespacing the bundle name with your project name will make sure you don't hit collisions.

Getting access to the bundle storage area for scanning isn't impossible, but it tends to require OSGi runtime specific information on how/where the bundles get extracted. So it's possible, but not easy.

James Branigan
Via OSGi, how to I know which plugins are available via non-installed bundles? I usually scan the classpath for a file that I put in the META-INF currently. It kind of seems that OSGi is incompatible with anything that currently uses the classpath for modularity."My non-OSGi enabled project currently scans for custom plugins via scanning the META-INF folders in my various plugin jars via Service.providers(...). If I go OSGi, will this mechanism still work?"
Chris
+1  A: 

spring has created osgi bundles of most of the open source libraries and i see jasper reports in there. check out their bundle repository @ http://www.springsource.com/repository/app/bundle

Pangea
A: 

Hi, we have been using Maven with OSGI, we declare the bundle dependencies in its pom.xml and you don't have to worry about them anymore.

cues7a
That is not entirely true, though. You need to obtain or create the bundles yourself (not everything is bundled), you need to let the bundles be deployed and manage the correct versioning (you can't just replace a bundle with a higher version - dependent bundles might need the older version) and so on. This is especially important if deployment is handled by a different division in the company - system administrators for instance.
extraneon