Reputation: 491
I am using struts2 for my web application and i want to use osgi architecture for service and dao layer. Now I dont want to wrap my struts2 actions as osgi bundles but want service and dao layer to be packaged as bundles. Now can anybody tell me how my non osgi actions can consume osgi bundles(service and dao layer). And I want to deploy my struts2 web application in web container so how web container will interact with osgi container(where my service and dao is deployed) in this case . Please help .
Upvotes: 3
Views: 1261
Reputation: 19606
Most surely this will not work. Why do you think it should be a good idea to move half of your application to OSGi? Either you should move all of it or none.
You may be able to deploy the struts layer in a war file and a access the OSGi services from it. I think this is possible in Virgo and Apache Karaf. It means to enhance the war with OSGi structures. For example in Karaf you can use a wab file which is a war file with a Manifest.
Upvotes: -1
Reputation: 2748
You need a so called 'bridge' between your web container and your OSGi environment. Both Felix and Equinox have that capability, but for me the Felix implementation worked much better.
What you basically want to do is:
So to access the web context from OSGi: Retrieve the ServletContext service, and go from there.
To access OSGi from the webcontext: Retrieve the OSGi framework from the ServletContext attribute and go from there.
Check the Felix Documentation, also I've made an example a while back on GitHub
Upvotes: 5