To embed OSGi in servlet container or servlet container in OSGi?
equinox, osgi, servlets, tomcat
Solution
First, does the code have any OSGi/Equinox dependencies besides the manifest? If not it should work just fine in a plain Tomcat.
My understanding is that embedding Tomcat in Equinox will change administering it heavily. Your folder layout including server.xml and catalina.sh will be gone. Instead you'll be managing an Equinox application probably through config admin.
Second there are two servlet programming and deployment models for OSGi. The first is HttpService in which you programmatically register your servlets and resources (you can also do this through an extension point). In this case your application is just a collection of bundles. However you can't use filters. The second is a web application bundle (WAB) which is an OSGified WAR.
Problem
I need to reuse code originally developed for an Eclipse RCP app (i.e. boxed as Eclipse plugin/OSGi bundle) in a servlet. After reading a lot of blog posts, articles, wikis and so on I ended up at the point where I know that: - An OSGi framework (Equinox in my case) can be embedded in a servlet container (Tomcat 7 in my case) - or Tomcat can be embedded in an OSGi framework. Equinox recommends the second option as being easier. But for production they recommend 1. I am unsure why. What is really better in which case and why? I am a quite seasoned Tomcat user, will embedding Tomcat in Equinox change administering it heavily? or in other words, what will be different in Tomcat embedded in Equinox?