Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Register a servlet on the fly: not currently possible?(Is currently possible to register a servlet in Virgo just a-la standard HttpService-way?)
icon12.gif  Register a servlet on the fly: not currently possible? [message #651073] Thu, 27 January 2011 16:58 Go to next message
Mario Scalas is currently offline Mario ScalasFriend
Messages: 32
Registered: July 2009
Member
I'm currently in need of deploying a legacy plugin (developed for plain Equinox / HttpService) onto virgo 2.1.0. I've noted that the standard HttpService.registerServlet() API does not work (there is no HttpService).

I don't want to bolt another web server (like Jetty, as I've read in the forums) into Virgo so before I put on a new strategy I'd like to know about these:


  • there is no way for a plugin to register a Servlet, either using the HttpService API or a-la PAX-web (register a javax.servlet.Servlet OSGi service): is it true? Will be supported in future versions?
  • I've to convert the bundle into a web-bundle and register my servlet using the web.xml? Is there any issue in doing this and having to reference OSGi services? Is there any example I can look at?


Thanks for any hint (or just reading Wink) !
Mario
Re: Register a servlet on the fly: not currently possible? [message #651102 is a reply to message #651073] Thu, 27 January 2011 18:30 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta GeorgievaFriend
Messages: 278
Registered: October 2010
Senior Member
Hi,

Find attached a very simple web app that lists the bundles on the system.
Put the .war file in the pickup directory then start Virgo.
When everything is started, request the application in the browser - http://localhost:8080/osgi-web-app

Two important things are:
- you can get the BundleContext from the ServletContext
(BundleContext) getServletContext().getAttribute("osgi-bundlecontext");

having the BundleContext you can use OSGi services

- you can specify the context path in the Manifest.mf
Web-ContextPath: /osgi-web-app


About HTTP service you may want to read this blog [1], some parts of it may be helpful.

Regards,
Violeta

[1] http://eclipsesource.com/blogs/2010/10/28/running-rap-on-vir go/

[Updated on: Thu, 27 January 2011 18:35]

Report message to a moderator

Re: Register a servlet on the fly: not currently possible? [message #651281 is a reply to message #651102] Fri, 28 January 2011 17:17 Go to previous message
Mario Scalas is currently offline Mario ScalasFriend
Messages: 32
Registered: July 2009
Member
Thanks: it is pretty simple (though not elegant, I'd say). BTW, I hope that in someway an HttpService implementation will get its way into Virgo Cool
Previous Topic:DuplicateLocationException when trying to refresh a problematic PAR
Next Topic:Spring, OSGi, Virgo, Gemini - the Big Picture?
Goto Forum:
  


Current Time: Fri Mar 29 15:15:22 GMT 2024

Powered by FUDForum. Page generated in 0.02166 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top