Well, do what you needed for a long time, a separate implementation and API ... ok, it's not always that simple on existing systems, but this model has a huge impact for your dollar. When your API is in a separate (much more stable) package / bank, you can compile clients and implementations against this package / jar.
One of the key qualities of a successful package is that it makes as few assumptions about the outside world as possible. This means that you do not need to compile packages that you work with at runtime, I prefer not to do this. You should only compile packages with a minimal set of dependencies. If assumptions are made, they are explicit as imported packages and use of services. Well-engineered OSGi systems try to use services for all interconnects. This model not only gets rid of problems with loading classes, but also makes your assembly more untied.
Unfortunately, most of the code is written in the form of libraries that have a fairly wide interface, because they pass code with many functions provided by services, such as Factories and Listeners. This code is tightly coupled between the implementation and the API, so you need to have the same thing on the class path at compile time and in OSGi. One solution to this problem is to include this type of code inside the package using it (but do not leak objects of this library into other packages). A bit of extra memory consumption, but it saves you some headaches.
So, with OSGi, try creating service-based systems and compiling their service API, not an implementation package.
Peter Kriens
source share