Rajani Karuturi
Rajani Karuturi

Reputation: 3503

how can i use jar which are not available as bundles in a osgi bundle?

I am moving my spring-java project to osgi.

I have some dependencies which are not available as bundles in the spring ebr repo or in maven repo. What are the best ways to handle them?

The options I can think of are

  1. create a local maven repo, convert the jars to bundles and use them ( this will become difficult with the transitive dependencies and updates of the jar)
  2. add them in the bundle classpath ( my bundle becomes huge and managing those jars is not easy with upgrades)
  3. keep all such jars in the classpath of another bundle, export the packages and use them ( again managing the jars is difficult)

Any other suggestions or which of the above is advisable?

Upvotes: 1

Views: 284

Answers (2)

Christian Schneider
Christian Schneider

Reputation: 19626

If you use apache karaf there is an option to bundle any jar from a maven repo on the fly. You just use the uri install -s wrap:mvn:groupId/artifactId/version. This will use bnd to bundle the jar with default settings and installs it. This works for example with the oracle jdbc driver.

Upvotes: 0

Dan Gravell
Dan Gravell

Reputation: 8275

The most advisable way is your first option, because that is the 'OSGi way'. This way you can better modularise your application and share the same bundle in different client bundles. You can also benefit from the version management inherent in OSGi.

You don't necessarily have to use Maven to create bundles from the JARs, although that may help. You can also use bnd to wrap a JAR as an OSGi bundle.

Upvotes: 4

Related Questions