John Todd wrote:The most famous OSGI usage in Java culture is Eclipse and Glassfish (and maybe NetBeans but I'm not sure), otherwise I didn't notice OSGI.
Is this because OSGI is complex? does this mean that the best OSGI use is for IDEs and servers? what about web applications or desktop applications?
I gave a "state of the union" overview in a presentation at Øredev 2010. They've not published the video yet, but you might find the slides useful:
http://www.slideshare.net/mcculls/redev-2010-what-happened-to-osgi
John Todd wrote:When do I know that I need OSGI for my project?
If you're about to create your own plugin framework, or write a custom classloader to run different versions of the same application, then I'd take a look at OSGi because it's a standard solution to those problems. As Richard says, don't just use OSGi for the sake of it - do it because it satisfies a requirement. That said, you might want to look at some OSGi programming "best-practices"
http://www.osgi.org/Links/BasicEducation so your code ready in case you need it in the future. Things like programming to interfaces, not assuming global classloader visibility (ie. use of Class.forName is a particular issue in OSGi) can make your code much more amenable to OSGi.
If you're providing a library for others then you might want to consider adding OSGi metadata to your JAR manifest - this is typically a painless process, but invaluable to OSGi users who want to use your library (we discuss this topic in the book).