How to use servlet with OSGi

前端 未结 6 1397
悲&欢浪女
悲&欢浪女 2021-01-11 19:31

I want to create and deploy a web service to OSGi container. For example, publish the service to the address:

http://localhost:8080/testservice. 

6条回答
  •  情书的邮戳
    2021-01-11 20:14

    You may find the following tutorial helpful: http://www.javabeat.net/2011/11/writing-an-osgi-web-application/. It's based on chapter two of Enterprise OSGi in Action. Chapter eight also has a discussion of how to use build tools like maven to get the right bundle structure, and http://coding.alasdair.info/2011/01/creating-web-application-bundle-using.html also has really helpful maven instructions.

    At a high level, your best route is probably to take advantage of something like Apache Aries or Eclipse Gemini to allow you to run a WAB (a web bundle). A WAB is structured almost exactly like a WAR, except that the manifest has OSGi metadata in it. Your servlet class itself would be identical to the non-OSGi case. The framework will handle discovering and launching your servlet.

提交回复
热议问题