I am learning OSGi framework. What i found that Bundles consists of .class files and manifest file. Now suppose I have two bundles A and B and bundle B depends on bundle A’s service. So while compiling bundle B i have to keep Bundle A’s service class in the classpath of bundle B or have to keep it(Bundle A’s service) inside bundle B so that compiler can compile. Now if we are doing so then how modularity is achieved and how the two bundles are independent. Please help.
Thanks
I am learning OSGi framework. What i found that Bundles consists of .class files
Share
Use interfaces!!
You have in interface
I. ClassAimplementsIand therefore depends on it, both at compile time and at runtime. ClassBuses an instance ofI, which it obtains as an OSGi Service. ThereforeBdepends onIat compile time and at runtime.Therefore neither
AnorBhas direct knowledge of each other. Implementation code is hidden, only the interface is visible and shared. And that’s how modularity is achieved.