Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting and importing same package from an osgi bundle

Tags:

java

maven

osgi

I have a class org.foo.Customer in an osgi bundle Bundle1 and another class org.foo.Subscriber in another osgi bundle Bundle2 in the same osgi environment. Bundle1 exports-package org.foo .

Is it possible to import org.foo package of Bundle2 by Bundle1. Will there be any conflict during runtime as the same package is specified in export and import in the manifest file of Bundle1 .

like image 515
bhavanak Avatar asked Dec 17 '25 06:12

bhavanak


1 Answers

Split packages are strongly discouraged in OSGi. If you own these bundles, you should either rename one or both packages, or join the split package into one bundle.

Bundle2 could import the split package, but then the classloader of Bundle2 would only see the classes in Bundle1, not those internally in Bundle2.

You could make one of the bundles a fragment of the other, which has the effect that they will use the same classloader. This requires changing only the manifest of the fragment bundle, and could be an option if you for some reason cannot join the bundles or change the package names.

like image 105
gjoranv Avatar answered Dec 19 '25 23:12

gjoranv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!