Abhishek Choudhary
Abhishek Choudhary

Reputation: 8395

How OSGi class loader behaves when I have 3 different jars to load and interdependency among them

I am self curios to know this answer. I have a problem like I have 3 jars A , B and C. Now jar A needed to import a version 1.1 of jar C and Jar B need to import a version 1.5 of jar C.

So, as per my understanding , is it like all these jar files will be loaded by seperate class loaders. So after getting loaded how OSGi going to handle different version scenario with specific jars.

Upvotes: 0

Views: 172

Answers (1)

Robin
Robin

Reputation: 24262

This scenario will require that there are four bundles deployed, A, B and C-1.1 and C-1.5.

  • A is resolved (with its own classloader) it will load any dependent classes from bundle C-1.1.

  • B is resolved (with its own classloader) it will load any dependent classes from bundle C-1.5.

This allows both versions of C to be able to be used in the same application, since they do not get loaded by the same classloader, so no conflict will exist with classes of the same name.

Upvotes: 1

Related Questions