Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Spring/Rest and OSGi HttpService
Spring/Rest and OSGi HttpService [message #759269] Mon, 28 November 2011 08:31 Go to next message
Leen Toelen is currently offline Leen ToelenFriend
Messages: 2
Registered: July 2009
Junior Member
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 08:32]

Report message to a moderator

Re: Spring/Rest and OSGi HttpService [message #760419 is a reply to message #759269] Fri, 02 December 2011 10:27 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

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.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Spring/Rest and OSGi HttpService [message #765498 is a reply to message #760419] Wed, 14 December 2011 07:45 Go to previous messageGo to next message
Leen Toelen is currently offline Leen ToelenFriend
Messages: 2
Registered: July 2009
Junior Member
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 07:45]

Report message to a moderator

Re: Spring/Rest and OSGi HttpService [message #771238 is a reply to message #765498] Mon, 26 December 2011 18:42 Go to previous message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

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.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Previous Topic:3.0.1 failed to build
Next Topic:Deploying webapp with Spring WebFlow
Goto Forum:
  


Current Time: Tue Apr 23 16:21:58 GMT 2024

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

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

Back to the top