Skip to main content



      Home
Home » Eclipse Projects » Virgo » Spring/Rest and OSGi HttpService
Spring/Rest and OSGi HttpService [message #759269] Mon, 28 November 2011 03:31 Go to next message
Eclipse UserFriend
Hi,

does anyone have an example on how to use a Bundle Activator or some other way of service registration and Spring REST support? I would like to add and remove REST resources dynamically using spring rest in virgo.

Regards,
Leen

[Updated on: Mon, 28 November 2011 03:32] by Moderator

Re: Spring/Rest and OSGi HttpService [message #760419 is a reply to message #759269] Fri, 02 December 2011 05:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I haven't used the Spring REST stuff but assuming it's just a servlet you will need to configure it programatically as the HttpService doesn't use a web.xml. Then in your bundle activator simply register and unregister the servlet in the HttpService. If the resources you want to expose over REST are other OSGi bundles or services use either a bundle event listener or a service tracker to respond to them and act as the glue to the HttpService.

That's all a fluffy, please give a bit more detail as to what you are trying to achieve and I'm sure I can help.

Chris.
Re: Spring/Rest and OSGi HttpService [message #765498 is a reply to message #760419] Wed, 14 December 2011 02:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I have a running equinox environment (quite bare bones) and an OSGi HttpService is registered as a Service. I would like to register a Servlet of my own. I normally do this by listening for HttpService services and then registering a servlet in it using registerServlet(alias,servlet,...,...)

The servlets I use currently are simple extenders of HttpServlets. I would like to use some spiring rest magic, like @Controller and @PathVariable annotations etc but I have not seen an example of how to create these programatically. the goal is to be able to add and remove these servlets at runtime of course.

Regards,
Leen

[Updated on: Wed, 14 December 2011 02:45] by Moderator

Re: Spring/Rest and OSGi HttpService [message #771238 is a reply to message #765498] Mon, 26 December 2011 13:42 Go to previous message
Eclipse UserFriend
Hi,

I don't know of any examples. Am I right in saying that you want to automatically deploy a servlet when a bundle is installed in OSGi that contains @Controller?

If so, I think you would have to write a bundle that listens to bundle install events and does it's own scanning for the annotations. Using Gemini Blueprint would help you with some of this though.

Have you considered using WABs. This will all just work with no extra code needed. WABs are defined in the Enterprise OSGi spec and are different to the HttpService but if you want to work with Spring features etc then you will probably find it much easier.

Chris.
Previous Topic:3.0.1 failed to build
Next Topic:Deploying webapp with Spring WebFlow
Goto Forum:
  


Current Time: Fri May 23 15:03:48 EDT 2025

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

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

Back to the top