Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import same package from different osgi bundles?

In my osgi project I have maven-bundle-plugin with instructions to import some path, for example: org.blah.blah.* And I have two other bundles that export such package. How to configure my bundle to import org.blah.blah.* from both of them?

like image 825
Jack Avatar asked Dec 26 '12 16:12

Jack


People also ask

What is the purpose of the export package manifest header in OSGi bundle?

This header declares the external dependencies of the bundle that the OSGi Framework uses to resolve the bundle. Specific versions or version ranges for each package can be declared.

What is the use of OSGi bundle?

OSGi facilitates creating and managing modular Java components (called bundles) that can be deployed in a container. As a developer, you use the OSGi specification and tools to create one or more bundles. OSGi defines the lifecycle for these bundles. It also hosts them and supports their interactions in a container.

What is an OSGi bundle?

OSGi is a Java framework for developing and deploying modular software programs and libraries. Each bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any).


1 Answers

You can't import a given package name from more than one bundle. What you could do is Require-Bundle both bundles which will give your bundle access to both packages as a split package with all the inherent issues of split packages and Require-Bundle. See 3.13.3 in the OSGi Core Release 5 spec.

Better would be to refactor (if you can) to avoid split packages.

like image 84
BJ Hargrave Avatar answered Sep 22 '22 04:09

BJ Hargrave