tags:

views:

71

answers:

1

Is it possible to introduce osgi-equinox into existing java Apache Tomcat project? From my understanding OSGI must run inside some kind of "container". How would I integrate it?

I am also using Jersey for RESTful resources.

+2  A: 

You may want to look at this question: http://stackoverflow.com/questions/3637679/osgi-runtime-inside-traditional-j2ee-server/3638309#3638309.

In this bridge model, a special servlet is installed and Tomcat invokes this servlet to handle the request. An OSGi runtime is spawned from within this servlet, but the OSGi runtime itself (e.g. equinox) is agnostic of things like HTTP. An OSGi HTTP service bundle is also installed, and you'll need to register your web app (servlet, jsp, ...) against this OSGi HTTP service to handle the incoming requests. Therefore, it is not like there is a separate "web server" to speak of that listens on its own port and manages HTTP on its own outside Tomcat. Your mileage may vary, but the overhead is basically limited to whatever the OSGi HTTP service might add when it forwards the request from the Tomcat connector to your servlet.

This bridge model is needed if you cannot change the existing deployment model. In the long run, a better model is to have the OSGi runtime first and have Tomcat (or any other OSGi-compliant container) plug into the OSGi runtime as bundles.

sjlee
I see, that is interesting. So you mean that another way is to run OSGI as a "web server" of it's own? But how does osgi's servers performance, compare to something like Apache?
drozzy
Is it possible to use something like Jersey with OSGi, which inspects the annotated classes and forwards the request to the given url to the appropriate class?
drozzy
I can't say because I haven't played with Jersey much, but web search for jersey + osgi seems to bring up a lot of contents.
sjlee