Chapter 12. Coping with the non-OSGi world
This chapter covers
- How to use existing third-party libraries with OSGi
- Patterns to avoid in OSGi where you can
- How to work around some common problems
- How to avoid doing more work than you need to
We’ve spent the majority of this book talking to you about how amazing OSGi is, and the fact that everybody should be using it. We believe this to be true, as do many others, but not everybody thinks of OSGi when writing their code. If they did, then there wouldn’t be much need for this book! Even though so many people do now think of OSGi, there are plenty of excellent libraries that have been in use for years, long before OSGi was as widely used as it is now.
We don’t expect enterprise OSGi developers to work in isolation from all of the non-OSGi code that exists. In fact, we would think you rather over-zealous if you tried to. Rather than having to give up all those useful libraries, or waiting for them to be packaged as OSGi bundles (which you should still ask for!), it’s important to learn how to work with what’s already out there.
When it comes to using existing code with OSGi, packaging isn’t the only problem; there are a number of other issues.